Add webp files and improve logging

This commit is contained in:
Cameron
2025-06-03 15:23:39 -04:00
parent 6aff7f456a
commit 7c882fd31c

View File

@@ -47,7 +47,7 @@ pub async fn list_photos<TagD: TagDao, FS: FileSystemAccess>(
if let Some(tag_ids) = &req.tag_ids {
if search_recursively {
let filter_mode = &req.tag_filter_mode.unwrap_or(FilterMode::Any);
debug!(
info!(
"Searching for tags: {}. With path: '{}' and filter mode: {:?}",
tag_ids, search_path, filter_mode
);
@@ -75,7 +75,7 @@ pub async fn list_photos<TagD: TagDao, FS: FileSystemAccess>(
tag_ids, filter_mode
))
.inspect(|files| {
debug!(
info!(
"Found {:?} tagged files, filtering down by search path {:?}",
files.len(),
search_path
@@ -100,7 +100,7 @@ pub async fn list_photos<TagD: TagDao, FS: FileSystemAccess>(
.map(|files| sort(files, req.sort.unwrap_or(NameAsc)))
.inspect(|files| debug!("Found {:?} files", files.len()))
.map(|tagged_files: Vec<String>| {
trace!(
info!(
"Found {:?} tagged files: {:?}",
tagged_files.len(),
tagged_files
@@ -119,7 +119,7 @@ pub async fn list_photos<TagD: TagDao, FS: FileSystemAccess>(
}
if let Ok(files) = file_system.get_files_for_path(search_path) {
debug!("Valid search path: {:?}", search_path);
info!("Found {:?} files in path: {:?}", files.len(), search_path);
let photos = files
.iter()
@@ -240,6 +240,7 @@ pub fn list_files(dir: &Path) -> io::Result<Vec<PathBuf>> {
let mut span = tracer.start("list_files");
let dir_name_string = dir.to_str().unwrap_or_default().to_string();
span.set_attribute(KeyValue::new("dir", dir_name_string));
info!("Listing files in: {:?}", dir);
let files = read_dir(dir)?
.filter_map(|res| res.ok())
@@ -248,6 +249,7 @@ pub fn list_files(dir: &Path) -> io::Result<Vec<PathBuf>> {
.collect::<Vec<PathBuf>>();
span.set_attribute(KeyValue::new("file_count", files.len().to_string()));
info!("Found {:?} files in directory: {:?}", files.len(), dir);
Ok(files)
}
@@ -263,6 +265,7 @@ pub fn is_image_or_video(path: &Path) -> bool {
|| extension == "mp4"
|| extension == "mov"
|| extension == "nef"
|| extension == "webp"
}
pub fn is_valid_full_path<P: AsRef<Path> + Debug + AsRef<std::ffi::OsStr>>(
@@ -319,6 +322,8 @@ pub async fn move_file<FS: FileSystemAccess>(
app_state: Data<AppState>,
request: web::Json<MoveFileRequest>,
) -> HttpResponse {
info!("Moving file: {:?}", request);
match is_valid_full_path(&app_state.base_path, &request.source, false)
.ok_or(ErrorKind::InvalidData)
.and_then(|source| {
@@ -358,7 +363,7 @@ pub async fn move_file<FS: FileSystemAccess>(
}
}
#[derive(Deserialize)]
#[derive(Deserialize, Debug)]
pub struct MoveFileRequest {
source: String,
destination: String,