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 <noreply@anthropic.com>
This commit is contained in:
Manav Rathi
2025-08-26 05:41:33 +05:30
parent 84f5a5ac3d
commit 042dae8790
2 changed files with 29 additions and 13 deletions

View File

@@ -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<i64, Vec<u8>>,
@@ -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(())
}
}

View File

@@ -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,