clippy + fmt

This commit is contained in:
nvrl committed 2026-06-30 03:29:40 +02:00
1 parent 9ec205f217
commit f702e56110
3 files changed
+23 -27

No files matched your search

+1 -6
View File
@@ -542,12 +542,7 @@ impl ProtonDriveClient {
/// Unlike [`download_file_to`](Self::download_file_to), a partial read /// Unlike [`download_file_to`](Self::download_file_to), a partial read
/// cannot recompute the full content manifest, so manifest-signature /// cannot recompute the full content manifest, so manifest-signature
/// verification is skipped. /// verification is skipped.
pub async fn download_range( pub async fn download_range(&self, uid: &NodeUid, offset: u64, length: u64) -> Result<Vec<u8>> {
&self,
uid: &NodeUid,
offset: u64,
length: u64,
) -> Result<Vec<u8>> {
let mut timer = self.telemetry.start("download_range"); let mut timer = self.telemetry.start("download_range");
let details = self let details = self
.get_link_details(&uid.volume_id, std::slice::from_ref(&uid.link_id)) .get_link_details(&uid.volume_id, std::slice::from_ref(&uid.link_id))
@@ -161,14 +161,14 @@ async fn download_range_single_block() {
let total = size as u64; let total = size as u64;
// (offset, length, expected slice end clamped to size) // (offset, length, expected slice end clamped to size)
let cases: &[(u64, u64)] = &[ let cases: &[(u64, u64)] = &[
(0, 100), // head (0, 100), // head
(1000, 5000), // interior (1000, 5000), // interior
(size as u64 - 10, 10), // exact tail (size as u64 - 10, 10), // exact tail
(size as u64 - 10, 1000), // past EOF → clamps to tail (size as u64 - 10, 1000), // past EOF → clamps to tail
(0, total), // whole file via range (0, total), // whole file via range
(total, 100), // offset == size → empty (total, 100), // offset == size → empty
(total + 50, 100), // offset past EOF → empty (total + 50, 100), // offset past EOF → empty
(1000, 0), // zero length → empty (1000, 0), // zero length → empty
]; ];
for &(off, len) in cases { for &(off, len) in cases {
@@ -180,7 +180,8 @@ async fn download_range_single_block() {
let to = ((off + len) as usize).min(size); let to = ((off + len) as usize).min(size);
let want = &payload[from..to]; let want = &payload[from..to];
assert_eq!( assert_eq!(
got, want, got,
want,
"range(off={off}, len={len}) mismatch: got {} bytes, want {}", "range(off={off}, len={len}) mismatch: got {} bytes, want {}",
got.len(), got.len(),
want.len() want.len()
@@ -231,14 +232,14 @@ async fn download_range_multi_block() {
let total = size as u64; let total = size as u64;
let cases: &[(u64, u64)] = &[ let cases: &[(u64, u64)] = &[
(0, 256), // start of block 1 (0, 256), // start of block 1
(block - 128, 256), // straddles block 1 → block 2 (block - 128, 256), // straddles block 1 → block 2
(block, 4096), // exact start of block 2 (block, 4096), // exact start of block 2
(2 * block - 1, 2), // straddles block 2 → block 3 (final short block) (2 * block - 1, 2), // straddles block 2 → block 3 (final short block)
(2 * block + 1000, 50_000),// interior of final short block (2 * block + 1000, 50_000), // interior of final short block
(total - 100, 500), // tail, length past EOF → clamps (total - 100, 500), // tail, length past EOF → clamps
(block - 10, block + 20), // spans a full block plus both neighbors (block - 10, block + 20), // spans a full block plus both neighbors
(0, total), // whole file (0, total), // whole file
]; ];
for &(off, len) in cases { for &(off, len) in cases {
+5 -5
View File
@@ -277,13 +277,13 @@ impl ApiHttpClient {
) -> Result<reqwest::Response> { ) -> Result<reqwest::Response> {
// Don't bother refreshing for terminal account states. // Don't bother refreshing for terminal account states.
let bytes = response.bytes().await?; let bytes = response.bytes().await?;
if let Ok(envelope) = serde_json::from_slice::<ApiResponse>(&bytes) { if let Ok(envelope) = serde_json::from_slice::<ApiResponse>(&bytes)
if matches!( && matches!(
envelope.code, envelope.code,
ResponseCode::AccountDeleted | ResponseCode::AccountDisabled ResponseCode::AccountDeleted | ResponseCode::AccountDisabled
) { )
return Err(api_error(StatusCode::UNAUTHORIZED, &bytes)); {
} return Err(api_error(StatusCode::UNAUTHORIZED, &bytes));
} }
let access_token = self.refresh_access_token(&rejected_access_token).await?; let access_token = self.refresh_access_token(&rejected_access_token).await?;