fix: per-library output path for face_trace spawn check + completeness check
- face_trace spawn 改用 get_output_dir_for_file 檢查 face_traced.json - completeness check 改用 per-library dir + global fallback - rust_store_traced_faces output_dir 改用 get_output_dir_for_file
This commit is contained in:
+23
-10
@@ -589,7 +589,7 @@ impl JobWorker {
|
|||||||
async fn periodic_completeness_check(&self) -> Result<()> {
|
async fn periodic_completeness_check(&self) -> Result<()> {
|
||||||
info!("[COMPLETENESS] Starting periodic output completeness check");
|
info!("[COMPLETENESS] Starting periodic output completeness check");
|
||||||
|
|
||||||
let output_dir = crate::core::config::OUTPUT_DIR.to_string();
|
let global_output_dir = crate::core::config::OUTPUT_DIR.to_string();
|
||||||
let videos_table = schema::table_name("videos");
|
let videos_table = schema::table_name("videos");
|
||||||
|
|
||||||
let rows: Vec<(String, String)> = sqlx::query_as(&format!(
|
let rows: Vec<(String, String)> = sqlx::query_as(&format!(
|
||||||
@@ -606,18 +606,31 @@ impl JobWorker {
|
|||||||
for (uuid, file_name) in &rows {
|
for (uuid, file_name) in &rows {
|
||||||
let mut missing: Vec<String> = Vec::new();
|
let mut missing: Vec<String> = Vec::new();
|
||||||
|
|
||||||
|
// Use per-library output dir with fallback to global
|
||||||
|
let per_lib_dir = crate::core::config::get_output_dir_for_file(uuid, self.db.pool()).await;
|
||||||
|
|
||||||
// 檢查 JSON 產出
|
// 檢查 JSON 產出
|
||||||
for ext in ["asrx", "cut", "face", "face_cluster", "face_traced", "ocr", "scenes"] {
|
for ext in ["asrx", "cut", "face", "face_cluster", "face_traced", "ocr", "scenes"] {
|
||||||
let path = format!("{}/{}.{}.json", output_dir, uuid, ext);
|
let filename = format!("{}.{}.json", uuid, ext);
|
||||||
if !std::path::Path::new(&path).exists() {
|
let per_lib_path = format!("{}/{}", per_lib_dir.trim_end_matches('/'), filename);
|
||||||
|
let global_path = format!("{}/{}", global_output_dir.trim_end_matches('/'), filename);
|
||||||
|
if !std::path::Path::new(&per_lib_path).exists() && !std::path::Path::new(&global_path).exists() {
|
||||||
missing.push(format!("{}.json", ext));
|
missing.push(format!("{}.json", ext));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 檢查 trace 目錄
|
// 檢查 trace 目錄
|
||||||
let trace_base = std::path::Path::new(&output_dir).join(uuid);
|
let trace_base = std::path::Path::new(&per_lib_dir).join(uuid);
|
||||||
if trace_base.is_dir() {
|
let trace_base_global = std::path::Path::new(&global_output_dir).join(uuid);
|
||||||
if let Ok(entries) = std::fs::read_dir(&trace_base) {
|
let effective_trace_base = if trace_base.is_dir() {
|
||||||
|
trace_base
|
||||||
|
} else if trace_base_global.is_dir() {
|
||||||
|
trace_base_global
|
||||||
|
} else {
|
||||||
|
std::path::PathBuf::new()
|
||||||
|
};
|
||||||
|
if effective_trace_base.is_dir() {
|
||||||
|
if let Ok(entries) = std::fs::read_dir(&effective_trace_base) {
|
||||||
for entry in entries.filter_map(|e| e.ok()) {
|
for entry in entries.filter_map(|e| e.ok()) {
|
||||||
let name = entry.file_name().to_string_lossy().to_string();
|
let name = entry.file_name().to_string_lossy().to_string();
|
||||||
if name.starts_with("trace_") && entry.path().is_dir() {
|
if name.starts_with("trace_") && entry.path().is_dir() {
|
||||||
@@ -4017,11 +4030,10 @@ async fn process_job(&self, job: crate::core::db::MonitorJob) -> Result<()> {
|
|||||||
// Note: trigger is gated on face alone (not has_asrx) so no-face videos still
|
// Note: trigger is gated on face alone (not has_asrx) so no-face videos still
|
||||||
// get face_traced.json written via the fast-path, unblocking FaceCluster.
|
// get face_traced.json written via the fast-path, unblocking FaceCluster.
|
||||||
if has_face {
|
if has_face {
|
||||||
|
let per_lib_dir = crate::core::config::get_output_dir_for_file(uuid, self.db.pool()).await;
|
||||||
let traced_path = format!(
|
let traced_path = format!(
|
||||||
"{}/{}.face_traced.json",
|
"{}/{}.face_traced.json",
|
||||||
crate::core::config::OUTPUT_DIR
|
per_lib_dir.trim_end_matches('/'),
|
||||||
.as_str()
|
|
||||||
.trim_end_matches('/'),
|
|
||||||
uuid
|
uuid
|
||||||
);
|
);
|
||||||
// ✅ V2: Check data integrity, not just file existence
|
// ✅ V2: Check data integrity, not just file existence
|
||||||
@@ -4215,7 +4227,8 @@ async fn process_job(&self, job: crate::core::db::MonitorJob) -> Result<()> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let output_dir = crate::core::config::OUTPUT_DIR.as_str();
|
let output_dir = crate::core::config::get_output_dir_for_file(&uuid_clone, db_clone.pool()).await;
|
||||||
|
let output_dir = output_dir.as_str();
|
||||||
|
|
||||||
// Get video path from DB for face crop extraction
|
// Get video path from DB for face crop extraction
|
||||||
let video_path: Option<String> = db_clone
|
let video_path: Option<String> = db_clone
|
||||||
|
|||||||
Reference in New Issue
Block a user