From a57e0bb4331147d31d0296b6639c57dda0607e04 Mon Sep 17 00:00:00 2001 From: Accusys Date: Thu, 19 Nov 2026 15:43:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20scan.rs=20stats=20API=20=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=20per-library=20=E8=B7=AF=E5=BE=91=20=E2=80=94=20?= =?UTF-8?q?=E4=BF=AE=E5=BE=A9=20Scene=20VLM=20=E6=95=B8=E9=87=8F=E4=B8=8D?= =?UTF-8?q?=E9=A1=AF=E7=A4=BA=20-=20get=5Ffile=5Fstats=5Finner:=20output?= =?UTF-8?q?=5Fdir=20=E6=94=B9=20per-library=EF=BC=88scene=5Fvlm/face=5Fclu?= =?UTF-8?q?ster/vlm=5Fsummary=20stats=EF=BC=89=20-=20get=5Fpipeline=5Fprog?= =?UTF-8?q?ress=5Fhandler:=20output=5Fdir=20=E6=94=B9=20per-library=20-=20?= =?UTF-8?q?get=5Fingestion=5Fstatus:=20scene=5Fmeta=5Fpath=20=E6=94=B9=20p?= =?UTF-8?q?er-library=20-=20get=5Fscene=5Fvlm=5Fstats:=20output=5Fdir=20?= =?UTF-8?q?=E6=94=B9=20per-library=20-=20=E9=A9=97=E8=AD=89:=20test=20libr?= =?UTF-8?q?ary=20scene-vlm-stats=20=E5=9B=9E=E5=82=B3=2018=20scenes,=2018/?= =?UTF-8?q?18=20done?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/scan.rs | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) 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() {