diff --git a/src/api/processing.rs b/src/api/processing.rs index 9f4e1941..b28dd525 100644 --- a/src/api/processing.rs +++ b/src/api/processing.rs @@ -935,7 +935,7 @@ struct OutputCompletenessItem { async fn get_output_completeness( State(state): State, ) -> Result, StatusCode> { - let output_dir = crate::core::config::OUTPUT_DIR.to_string(); + let global_dir = crate::core::config::OUTPUT_DIR.as_str(); let videos_table = schema::table_name("videos"); let rows: Vec<(String, String, String)> = sqlx::query_as(&format!( @@ -956,13 +956,25 @@ async fn get_output_completeness( continue; // 只檢查 completed 的影片 } + // Per-library output dir with global fallback (test files live in output/test) + let per_lib = crate::core::config::get_output_dir_for_file(&uuid, state.db.pool()).await; + let output_dir = if std::path::Path::new(&per_lib).is_dir() { + per_lib + } else { + global_dir.to_string() + }; + let mut missing = Vec::new(); // 檢查 JSON 產出 for ext in ["asrx", "cut", "face", "face_cluster", "face_traced", "ocr", "scenes"] { let path = format!("{}/{}.{}.json", output_dir, uuid, ext); if !std::path::Path::new(&path).exists() { - missing.push(format!("{}.json", ext)); + // fallback to global dir + let global_path = format!("{}/{}.{}.json", global_dir, uuid, ext); + if !std::path::Path::new(&global_path).exists() { + missing.push(format!("{}.json", ext)); + } } }