From 7c882fd31c32ce52d99d168be16bd12c70da78c9 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 3 Jun 2025 15:23:39 -0400 Subject: [PATCH] Add webp files and improve logging --- src/files.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/files.rs b/src/files.rs index 9afef7e..af2a47a 100644 --- a/src/files.rs +++ b/src/files.rs @@ -47,7 +47,7 @@ pub async fn list_photos( 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( 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( .map(|files| sort(files, req.sort.unwrap_or(NameAsc))) .inspect(|files| debug!("Found {:?} files", files.len())) .map(|tagged_files: Vec| { - trace!( + info!( "Found {:?} tagged files: {:?}", tagged_files.len(), tagged_files @@ -119,7 +119,7 @@ pub async fn list_photos( } 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> { 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> { .collect::>(); 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 + Debug + AsRef>( @@ -319,6 +322,8 @@ pub async fn move_file( app_state: Data, request: web::Json, ) -> 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( } } -#[derive(Deserialize)] +#[derive(Deserialize, Debug)] pub struct MoveFileRequest { source: String, destination: String,