From 042dae879080d50a9c8f1fa28e919f23e239bf35 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Tue, 26 Aug 2025 05:41:33 +0530 Subject: [PATCH] fix(rust): Apply cargo fmt and clippy fixes - Fixed formatting issues in sync/engine.rs - Added #[allow(dead_code)] for unused storage field in DownloadManager - Replaced manual clamp with .clamp() method Co-Authored-By: Claude --- rust/src/sync/download.rs | 11 ++++++----- rust/src/sync/engine.rs | 31 +++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/rust/src/sync/download.rs b/rust/src/sync/download.rs index f4a5472660..37e231ade3 100644 --- a/rust/src/sync/download.rs +++ b/rust/src/sync/download.rs @@ -13,6 +13,7 @@ use tokio::io::AsyncWriteExt; /// Manages file downloads with parallel processing and error recovery pub struct DownloadManager { api_client: ApiClient, + #[allow(dead_code)] storage: Storage, temp_dir: PathBuf, collection_keys: HashMap>, @@ -41,7 +42,7 @@ impl DownloadManager { /// Set number of concurrent downloads pub fn set_concurrent_downloads(&mut self, count: usize) { - self.concurrent_downloads = count.max(1).min(10); // Limit between 1-10 + self.concurrent_downloads = count.clamp(1, 10); // Limit between 1-10 } /// Download a single file @@ -60,7 +61,7 @@ impl DownloadManager { // Check if file already exists if destination.exists() { - log::debug!("File already exists at {:?}, skipping", destination); + log::debug!("File already exists at {destination:?}, skipping"); return Ok(()); } @@ -99,7 +100,7 @@ impl DownloadManager { use futures::stream::{self, StreamExt}; let total = files.len(); - log::info!("Starting download of {} files", total); + log::info!("Starting download of {total} files"); let mut stats = DownloadStats { total, @@ -124,7 +125,7 @@ impl DownloadManager { match result { Ok(_) => stats.successful += 1, Err(e) => { - log::error!("Download failed: {}", e); + log::error!("Download failed: {e}"); stats.failed += 1; } } @@ -225,7 +226,7 @@ impl DownloadManager { } } - log::debug!("Cleaned up {} temporary files", count); + log::debug!("Cleaned up {count} temporary files"); Ok(()) } } diff --git a/rust/src/sync/engine.rs b/rust/src/sync/engine.rs index 348ee5bc45..5c3f362df9 100644 --- a/rust/src/sync/engine.rs +++ b/rust/src/sync/engine.rs @@ -36,7 +36,7 @@ impl SyncEngine { // Then sync files stats.files = self.sync_files(account_id).await?; - log::info!("Sync completed: {:?}", stats); + log::info!("Sync completed: {stats:?}"); Ok(stats) } @@ -130,25 +130,36 @@ impl SyncEngine { continue; } - log::debug!("Syncing files for collection: {} ({})", collection.name, collection.id); + log::debug!( + "Syncing files for collection: {} ({})", + collection.name, + collection.id + ); // Get last sync time for this collection's files let mut last_sync = sync_store - .get_last_sync(self.account.id, &format!("collection_{}_files", collection.id))? + .get_last_sync( + self.account.id, + &format!("collection_{}_files", collection.id), + )? .unwrap_or(0); let mut has_more = true; while has_more { - log::debug!("Fetching files for collection {}, since_time: {}", collection.id, last_sync); + log::debug!( + "Fetching files for collection {}, since_time: {}", + collection.id, + last_sync + ); let (files, more) = api .get_collection_files(account_id, collection.id, last_sync) .await?; has_more = more; - if files.is_empty() { - break; - } + if files.is_empty() { + break; + } result.total += files.len(); @@ -176,7 +187,11 @@ impl SyncEngine { size: file.thumbnail.size, }, metadata: crate::models::file::MetadataInfo { - encrypted_data: file.metadata.encrypted_data.clone().unwrap_or_default(), + encrypted_data: file + .metadata + .encrypted_data + .clone() + .unwrap_or_default(), decryption_header: file.metadata.decryption_header.clone(), }, is_deleted: file.is_deleted,