diff --git a/src/files.rs b/src/files.rs index 21222d8..266f1d3 100644 --- a/src/files.rs +++ b/src/files.rs @@ -73,7 +73,11 @@ fn move_file_cross_platform(source: &Path, target: &Path) -> io::Result<()> { } } -pub fn execute_move(base_path: &Path, plan: OrganizationPlan, mut undo_log: Option<&mut crate::undo::UndoLog>) { +pub fn execute_move( + base_path: &Path, + plan: OrganizationPlan, + mut undo_log: Option<&mut crate::undo::UndoLog>, +) { println!("\n{}", "--- EXECUTION PLAN ---".bold().underline()); if plan.files.is_empty() { @@ -140,7 +144,7 @@ pub fn execute_move(base_path: &Path, plan: OrganizationPlan, mut undo_log: Opti if let Ok(metadata) = fs::metadata(&source) { if metadata.is_file() { - match move_file_cross_platform(&source, &target) { + match move_file_cross_platform(&source, &target) { Ok(_) => { if item.sub_category.is_empty() { println!("Moved: {} -> {}/", item.filename, item.category.green()); @@ -197,7 +201,8 @@ pub fn undo_moves( undo_log: &mut crate::undo::UndoLog, dry_run: bool, ) -> Result<(usize, usize, usize), Box> { - let completed_moves: Vec<_> = undo_log.get_completed_moves() + let completed_moves: Vec<_> = undo_log + .get_completed_moves() .into_iter() .cloned() .collect(); @@ -208,7 +213,11 @@ pub fn undo_moves( } println!("\n{}", "--- UNDO PREVIEW ---".bold().underline()); - println!("{} will restore {} files:", "INFO:".cyan(), completed_moves.len()); + println!( + "{} will restore {} files:", + "INFO:".cyan(), + completed_moves.len() + ); for record in &completed_moves { if let Ok(rel_dest) = record.destination_path.strip_prefix(base_path) { @@ -326,11 +335,7 @@ fn cleanup_empty_directories( && entries.next().is_none() && fs::remove_dir(&full_path).is_ok() { - println!( - "{} Removed empty directory: {}", - "INFO:".cyan(), - dir_path - ); + println!("{} Removed empty directory: {}", "INFO:".cyan(), dir_path); } } diff --git a/src/undo.rs b/src/undo.rs index a2ab1bb..dc22c49 100644 --- a/src/undo.rs +++ b/src/undo.rs @@ -48,10 +48,7 @@ impl UndoLog { match fs::read_to_string(undo_log_path) { Ok(content) => match serde_json::from_str::(&content) { Ok(log) => { - println!( - "Loaded undo log with {} entries", - log.get_completed_count() - ); + println!("Loaded undo log with {} entries", log.get_completed_count()); log } Err(_) => { @@ -162,10 +159,7 @@ impl UndoLog { let removed_count = initial_count - self.entries.len(); if removed_count > 0 { - println!( - "Cleaned up {} old undo log entries", - removed_count - ); + println!("Cleaned up {} old undo log entries", removed_count); } if self.entries.len() > self.max_entries { @@ -211,10 +205,11 @@ impl UndoLog { for entry in &self.entries { if entry.status == MoveStatus::Completed && let Ok(rel_path) = entry.destination_path.strip_prefix(base_path) - && let Some(parent) = rel_path.parent() { - let dir_path = parent.to_string_lossy().into_owned(); - *usage.entry(dir_path).or_insert(0) += 1; - } + && let Some(parent) = rel_path.parent() + { + let dir_path = parent.to_string_lossy().into_owned(); + *usage.entry(dir_path).or_insert(0) += 1; + } } usage diff --git a/src/undo_tests.rs b/src/undo_tests.rs index 7087e61..70e7023 100644 --- a/src/undo_tests.rs +++ b/src/undo_tests.rs @@ -1,6 +1,6 @@ use super::*; -use tempfile::TempDir; use std::fs; +use tempfile::TempDir; #[test] fn test_undo_log_creation() { @@ -77,7 +77,8 @@ fn test_cleanup_old_entries() { let old_timestamp = SystemTime::now() .duration_since(UNIX_EPOCH) .unwrap() - .as_secs() - (10 * 24 * 60 * 60); + .as_secs() + - (10 * 24 * 60 * 60); let source = PathBuf::from("/test/source.txt"); let dest = PathBuf::from("/test/dest/source.txt");