feature/exif-endpoint #44

Merged
cameron merged 29 commits from feature/exif-endpoint into master 2025-12-27 03:25:19 +00:00
5 changed files with 32 additions and 23 deletions
Showing only changes of commit b4c5a38c9d - Show all commits

View File

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

View File

@@ -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;
}
}

View File

@@ -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<String> {
fn find_file_with_alternative_extension(
base_path: &PathBuf,
relative_path: &str,
) -> Option<String> {
let full_path = base_path.join(relative_path);
// Get the parent directory and file stem (name without extension)

View File

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

View File

@@ -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<Vec<String>>;
fn get_all_photo_names(
&mut self,
context: &opentelemetry::Context,
) -> anyhow::Result<Vec<String>>;
}
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<Vec<String>> {
fn get_all_photo_names(
&mut self,
context: &opentelemetry::Context,
) -> anyhow::Result<Vec<String>> {
todo!()
}
}