fixed formatting

This commit is contained in:
glitchySid
2025-12-29 21:54:11 +05:30
parent 79cfae74ea
commit a7668a6f0f
3 changed files with 24 additions and 23 deletions

View File

@@ -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() {
@@ -197,7 +201,8 @@ pub fn undo_moves(
undo_log: &mut crate::undo::UndoLog,
dry_run: bool,
) -> Result<(usize, usize, usize), Box<dyn std::error::Error>> {
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);
}
}

View File

@@ -48,10 +48,7 @@ impl UndoLog {
match fs::read_to_string(undo_log_path) {
Ok(content) => match serde_json::from_str::<UndoLog>(&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,7 +205,8 @@ 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 Some(parent) = rel_path.parent()
{
let dir_path = parent.to_string_lossy().into_owned();
*usage.entry(dir_path).or_insert(0) += 1;
}

View File

@@ -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");