Refactor file type checking for better consistency
Fix tests
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -183,26 +183,8 @@ pub fn validate_file_types(
|
||||
|
||||
/// Check if a file is a supported media file based on extension
|
||||
fn is_supported_media_file(path: &Path) -> bool {
|
||||
if let Some(ext) = path.extension()
|
||||
&& let Some(ext_str) = ext.to_str() {
|
||||
let ext_lower = ext_str.to_lowercase();
|
||||
return matches!(
|
||||
ext_lower.as_str(),
|
||||
"jpg"
|
||||
| "jpeg"
|
||||
| "png"
|
||||
| "webp"
|
||||
| "tiff"
|
||||
| "tif"
|
||||
| "heif"
|
||||
| "heic"
|
||||
| "avif"
|
||||
| "nef"
|
||||
| "mp4"
|
||||
| "mov"
|
||||
);
|
||||
}
|
||||
false
|
||||
use crate::file_types::is_media_file;
|
||||
is_media_file(path)
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
||||
Reference in New Issue
Block a user