diff --git a/src/bin/cleanup_files.rs b/src/bin/cleanup_files.rs index 5b938d4..7211d5e 100644 --- a/src/bin/cleanup_files.rs +++ b/src/bin/cleanup_files.rs @@ -4,7 +4,7 @@ use std::sync::{Arc, Mutex}; use clap::Parser; use image_api::cleanup::{ - resolve_missing_files, validate_file_types, CleanupConfig, DatabaseUpdater, + CleanupConfig, DatabaseUpdater, resolve_missing_files, validate_file_types, }; use image_api::database::{SqliteExifDao, SqliteFavoriteDao}; use image_api::tags::SqliteTagDao; diff --git a/src/cleanup/database_updater.rs b/src/cleanup/database_updater.rs index 4f6c79d..9eb287e 100644 --- a/src/cleanup/database_updater.rs +++ b/src/cleanup/database_updater.rs @@ -1,6 +1,6 @@ use crate::database::{ExifDao, FavoriteDao}; use crate::tags::TagDao; -use anyhow::{Context, Result}; +use anyhow::Result; use log::{error, info}; use opentelemetry; use std::sync::{Arc, Mutex}; @@ -39,10 +39,7 @@ impl DatabaseUpdater { success_count += 1; } Err(e) => { - error!( - "Failed to update tagged_photo for {}: {:?}", - old_path, e - ); + error!("Failed to update tagged_photo for {}: {:?}", old_path, e); error_count += 1; } } diff --git a/src/cleanup/phase1.rs b/src/cleanup/phase1.rs index 910df4d..20dabfe 100644 --- a/src/cleanup/phase1.rs +++ b/src/cleanup/phase1.rs @@ -1,7 +1,7 @@ use crate::cleanup::database_updater::DatabaseUpdater; use crate::cleanup::types::{CleanupConfig, CleanupStats}; use anyhow::Result; -use log::{error, info, warn}; +use log::{error, warn}; use std::path::PathBuf; // All supported image extensions to try @@ -95,7 +95,10 @@ pub fn resolve_missing_files( /// Find a file with an alternative extension /// Returns the relative path with the new extension if found -fn find_file_with_alternative_extension(base_path: &PathBuf, relative_path: &str) -> Option { +fn find_file_with_alternative_extension( + base_path: &PathBuf, + relative_path: &str, +) -> Option { let full_path = base_path.join(relative_path); // Get the parent directory and file stem (name without extension) diff --git a/src/cleanup/phase2.rs b/src/cleanup/phase2.rs index a9311af..22fafc6 100644 --- a/src/cleanup/phase2.rs +++ b/src/cleanup/phase2.rs @@ -1,9 +1,8 @@ use crate::cleanup::database_updater::DatabaseUpdater; use crate::cleanup::file_type_detector::{detect_file_type, should_rename}; use crate::cleanup::types::{CleanupConfig, CleanupStats}; -use anyhow::{Context, Result}; -use dialoguer::Confirm; -use log::{error, info, warn}; +use anyhow::Result; +use log::{error, warn}; use std::fs; use std::path::{Path, PathBuf}; use walkdir::WalkDir; @@ -79,10 +78,7 @@ pub fn validate_file_types( // Check if destination already exists if new_file_path.exists() { - warn!( - "✗ Destination already exists: {}", - new_relative_path - ); + warn!("✗ Destination already exists: {}", new_relative_path); stats.add_error(format!( "Destination exists for {}: {}", relative_path, new_relative_path @@ -127,8 +123,7 @@ pub fn validate_file_types( println!("✓ Renamed file"); // Update database - match db_updater - .update_file_path(relative_path, new_relative_path) + match db_updater.update_file_path(relative_path, new_relative_path) { Ok(_) => { files_renamed += 1; @@ -148,7 +143,10 @@ pub fn validate_file_types( } Err(e) => { error!("✗ Failed to rename file: {:?}", e); - stats.add_error(format!("Rename failed for {}: {}", relative_path, e)); + stats.add_error(format!( + "Rename failed for {}: {}", + relative_path, e + )); } } } @@ -190,7 +188,8 @@ fn is_supported_media_file(path: &Path) -> bool { let ext_lower = ext_str.to_lowercase(); return matches!( ext_lower.as_str(), - "jpg" | "jpeg" + "jpg" + | "jpeg" | "png" | "webp" | "tiff" diff --git a/src/tags.rs b/src/tags.rs index fa83f23..bf74d3c 100644 --- a/src/tags.rs +++ b/src/tags.rs @@ -309,8 +309,10 @@ pub trait TagDao { new_name: &str, context: &opentelemetry::Context, ) -> anyhow::Result<()>; - fn get_all_photo_names(&mut self, context: &opentelemetry::Context) - -> anyhow::Result>; + fn get_all_photo_names( + &mut self, + context: &opentelemetry::Context, + ) -> anyhow::Result>; } pub struct SqliteTagDao { @@ -772,11 +774,19 @@ mod tests { todo!() } - fn update_photo_name(&mut self, old_name: &str, new_name: &str, context: &opentelemetry::Context) -> anyhow::Result<()> { + fn update_photo_name( + &mut self, + old_name: &str, + new_name: &str, + context: &opentelemetry::Context, + ) -> anyhow::Result<()> { todo!() } - fn get_all_photo_names(&mut self, context: &opentelemetry::Context) -> anyhow::Result> { + fn get_all_photo_names( + &mut self, + context: &opentelemetry::Context, + ) -> anyhow::Result> { todo!() } }