Refactor file type checking for better consistency

Fix tests
This commit is contained in:
Cameron
2025-12-23 22:30:53 -05:00
parent 6dbac6f22f
commit 636701a69e
7 changed files with 170 additions and 132 deletions

View File

@@ -1,13 +1,12 @@
use crate::cleanup::database_updater::DatabaseUpdater;
use crate::cleanup::types::{CleanupConfig, CleanupStats};
use crate::file_types::IMAGE_EXTENSIONS;
use anyhow::Result;
use log::{error, warn};
use std::path::PathBuf;
// All supported image extensions to try
const SUPPORTED_EXTENSIONS: &[&str] = &[
"jpg", "jpeg", "png", "webp", "tiff", "tif", "heif", "heic", "avif", "nef",
];
const SUPPORTED_EXTENSIONS: &[&str] = IMAGE_EXTENSIONS;
/// Phase 1: Resolve missing files by searching for alternative extensions
pub fn resolve_missing_files(
@@ -111,9 +110,10 @@ fn find_file_with_alternative_extension(
if test_path.exists() {
// Convert back to relative path
if let Ok(rel) = test_path.strip_prefix(base_path)
&& let Some(rel_str) = rel.to_str() {
return Some(rel_str.to_string());
}
&& let Some(rel_str) = rel.to_str()
{
return Some(rel_str.to_string());
}
}
}