Cargo fmt
This commit is contained in:
@@ -4,7 +4,7 @@ use std::sync::{Arc, Mutex};
|
|||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
use image_api::cleanup::{
|
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::database::{SqliteExifDao, SqliteFavoriteDao};
|
||||||
use image_api::tags::SqliteTagDao;
|
use image_api::tags::SqliteTagDao;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::database::{ExifDao, FavoriteDao};
|
use crate::database::{ExifDao, FavoriteDao};
|
||||||
use crate::tags::TagDao;
|
use crate::tags::TagDao;
|
||||||
use anyhow::{Context, Result};
|
use anyhow::Result;
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
use opentelemetry;
|
use opentelemetry;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
@@ -39,10 +39,7 @@ impl DatabaseUpdater {
|
|||||||
success_count += 1;
|
success_count += 1;
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!(
|
error!("Failed to update tagged_photo for {}: {:?}", old_path, e);
|
||||||
"Failed to update tagged_photo for {}: {:?}",
|
|
||||||
old_path, e
|
|
||||||
);
|
|
||||||
error_count += 1;
|
error_count += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use crate::cleanup::database_updater::DatabaseUpdater;
|
use crate::cleanup::database_updater::DatabaseUpdater;
|
||||||
use crate::cleanup::types::{CleanupConfig, CleanupStats};
|
use crate::cleanup::types::{CleanupConfig, CleanupStats};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use log::{error, info, warn};
|
use log::{error, warn};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
// All supported image extensions to try
|
// All supported image extensions to try
|
||||||
@@ -95,7 +95,10 @@ pub fn resolve_missing_files(
|
|||||||
|
|
||||||
/// Find a file with an alternative extension
|
/// Find a file with an alternative extension
|
||||||
/// Returns the relative path with the new extension if found
|
/// Returns the relative path with the new extension if found
|
||||||
fn find_file_with_alternative_extension(base_path: &PathBuf, relative_path: &str) -> Option<String> {
|
fn find_file_with_alternative_extension(
|
||||||
|
base_path: &PathBuf,
|
||||||
|
relative_path: &str,
|
||||||
|
) -> Option<String> {
|
||||||
let full_path = base_path.join(relative_path);
|
let full_path = base_path.join(relative_path);
|
||||||
|
|
||||||
// Get the parent directory and file stem (name without extension)
|
// Get the parent directory and file stem (name without extension)
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
use crate::cleanup::database_updater::DatabaseUpdater;
|
use crate::cleanup::database_updater::DatabaseUpdater;
|
||||||
use crate::cleanup::file_type_detector::{detect_file_type, should_rename};
|
use crate::cleanup::file_type_detector::{detect_file_type, should_rename};
|
||||||
use crate::cleanup::types::{CleanupConfig, CleanupStats};
|
use crate::cleanup::types::{CleanupConfig, CleanupStats};
|
||||||
use anyhow::{Context, Result};
|
use anyhow::Result;
|
||||||
use dialoguer::Confirm;
|
use log::{error, warn};
|
||||||
use log::{error, info, warn};
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
@@ -79,10 +78,7 @@ pub fn validate_file_types(
|
|||||||
|
|
||||||
// Check if destination already exists
|
// Check if destination already exists
|
||||||
if new_file_path.exists() {
|
if new_file_path.exists() {
|
||||||
warn!(
|
warn!("✗ Destination already exists: {}", new_relative_path);
|
||||||
"✗ Destination already exists: {}",
|
|
||||||
new_relative_path
|
|
||||||
);
|
|
||||||
stats.add_error(format!(
|
stats.add_error(format!(
|
||||||
"Destination exists for {}: {}",
|
"Destination exists for {}: {}",
|
||||||
relative_path, new_relative_path
|
relative_path, new_relative_path
|
||||||
@@ -127,8 +123,7 @@ pub fn validate_file_types(
|
|||||||
println!("✓ Renamed file");
|
println!("✓ Renamed file");
|
||||||
|
|
||||||
// Update database
|
// Update database
|
||||||
match db_updater
|
match db_updater.update_file_path(relative_path, new_relative_path)
|
||||||
.update_file_path(relative_path, new_relative_path)
|
|
||||||
{
|
{
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
files_renamed += 1;
|
files_renamed += 1;
|
||||||
@@ -148,7 +143,10 @@ pub fn validate_file_types(
|
|||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("✗ Failed to rename file: {:?}", 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();
|
let ext_lower = ext_str.to_lowercase();
|
||||||
return matches!(
|
return matches!(
|
||||||
ext_lower.as_str(),
|
ext_lower.as_str(),
|
||||||
"jpg" | "jpeg"
|
"jpg"
|
||||||
|
| "jpeg"
|
||||||
| "png"
|
| "png"
|
||||||
| "webp"
|
| "webp"
|
||||||
| "tiff"
|
| "tiff"
|
||||||
|
|||||||
18
src/tags.rs
18
src/tags.rs
@@ -309,8 +309,10 @@ pub trait TagDao {
|
|||||||
new_name: &str,
|
new_name: &str,
|
||||||
context: &opentelemetry::Context,
|
context: &opentelemetry::Context,
|
||||||
) -> anyhow::Result<()>;
|
) -> anyhow::Result<()>;
|
||||||
fn get_all_photo_names(&mut self, context: &opentelemetry::Context)
|
fn get_all_photo_names(
|
||||||
-> anyhow::Result<Vec<String>>;
|
&mut self,
|
||||||
|
context: &opentelemetry::Context,
|
||||||
|
) -> anyhow::Result<Vec<String>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SqliteTagDao {
|
pub struct SqliteTagDao {
|
||||||
@@ -772,11 +774,19 @@ mod tests {
|
|||||||
todo!()
|
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!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_all_photo_names(&mut self, context: &opentelemetry::Context) -> anyhow::Result<Vec<String>> {
|
fn get_all_photo_names(
|
||||||
|
&mut self,
|
||||||
|
context: &opentelemetry::Context,
|
||||||
|
) -> anyhow::Result<Vec<String>> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user