diff --git a/src/api/scan.rs b/src/api/scan.rs index b61eb52d..c7d570b3 100644 --- a/src/api/scan.rs +++ b/src/api/scan.rs @@ -544,11 +544,14 @@ async fn get_ingestion_status( let identity_count = identity_ids.len() as i64; let strangers = stranger_traces.len() as i64; - let scene_meta_path = format!( - "{}/{}.scene_meta.json", - crate::core::config::OUTPUT_DIR.as_str(), - file_uuid - ); + let per_lib_dir = crate::core::config::get_output_dir_for_file(&file_uuid, pool).await; + let global_dir = crate::core::config::OUTPUT_DIR.as_str(); + let scene_meta_base = if std::path::Path::new(&per_lib_dir).is_dir() { + per_lib_dir + } else { + global_dir.to_string() + }; + let scene_meta_path = format!("{}/{}.scene_meta.json", scene_meta_base, file_uuid); let scene_meta_ok = std::path::Path::new(&scene_meta_path).exists(); macro_rules! count_sql { @@ -1153,8 +1156,15 @@ async fn get_file_stats_inner( ..Default::default() }; + let global_dir = crate::core::config::OUTPUT_DIR.as_str(); + let per_lib_dir = crate::core::config::get_output_dir_for_file(&file_uuid, pool).await; + let output_dir: &str = if std::path::Path::new(&per_lib_dir).is_dir() { + &per_lib_dir + } else { + global_dir + }; + // 6. Get Face Dedup stats - let output_dir = crate::core::config::OUTPUT_DIR.as_str(); let face_cluster_path = format!("{}/{}.face_cluster.json", output_dir, file_uuid); let face_clusters = if std::path::Path::new(&face_cluster_path).exists() { if let Ok(content) = std::fs::read_to_string(&face_cluster_path) { @@ -1330,6 +1340,15 @@ async fn get_pipeline_progress_handler( State(state): State, Path(file_uuid): Path, ) -> Result, StatusCode> { + // Per-library output dir (test files live in output/test) + let per_lib_dir = crate::core::config::get_output_dir_for_file(&file_uuid, state.db.pool()).await; + let global_dir = crate::core::config::OUTPUT_DIR.as_str(); + let output_dir: &str = if std::path::Path::new(&per_lib_dir).is_dir() { + &per_lib_dir + } else { + global_dir + }; + // 1. Try to read existing progress from Redis first let redis_progress: Option = { use crate::core::db::RedisClient; @@ -1521,7 +1540,6 @@ async fn get_pipeline_progress_handler( // Check scene_vlm progress from scenes.json - let output_dir = crate::core::config::OUTPUT_DIR.as_str(); let scenes_path = format!("{}/{}.scenes.json", output_dir, file_uuid); if std::path::Path::new(&scenes_path).exists() { if let Ok(scenes_json) = std::fs::read_to_string(&scenes_path) { @@ -1578,7 +1596,6 @@ async fn get_pipeline_progress_handler( // Check face dedup from actual face_cluster.json content // Always check if processors_done, regardless of tkg_node_count (A-10 fix) if processors_done { - let output_dir = crate::core::config::OUTPUT_DIR.as_str(); let face_cluster_path = format!("{}/{}.face_cluster.json", output_dir, file_uuid); if std::path::Path::new(&face_cluster_path).exists() { if let Ok(content) = std::fs::read_to_string(&face_cluster_path) { @@ -1649,7 +1666,13 @@ pub async fn get_scene_vlm_stats( State(state): State, Path(file_uuid): Path, ) -> Result, StatusCode> { - let output_dir = crate::core::config::OUTPUT_DIR.to_string(); + let per_lib = crate::core::config::get_output_dir_for_file(&file_uuid, state.db.pool()).await; + let global_dir = crate::core::config::OUTPUT_DIR.as_str(); + let output_dir = if std::path::Path::new(&per_lib).is_dir() { + per_lib + } else { + global_dir.to_string() + }; let scenes_path = format!("{}/{}.scenes.json", output_dir, file_uuid); if !std::path::Path::new(&scenes_path).exists() {