From 0558cd7615b093b5f6b3c6b0b8085051f5136467 Mon Sep 17 00:00:00 2001 From: Accusys Date: Sun, 27 Sep 2026 08:23:02 +0800 Subject: [PATCH] fix: add data integrity check for Face Tracing Problem: - Worker only checked face_traced.json existence - Didn't verify traced_faces/ directory exists - Didn't check if directory has files - Result: incomplete traces marked as complete Solution: - Check traced_faces/ directory exists - Check directory has files (file_count > 0) - Remove incomplete face_traced.json if trace incomplete - Re-run Face Tracing for incomplete traces Impact: - Prevents false "already done" detection - Ensures data integrity before skipping - Auto-repairs incomplete traces Fixes: - 020.mp4 stuck at 40% issue - Similar stuck cases with missing traced_faces/ --- src/worker/job_worker.rs | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/worker/job_worker.rs b/src/worker/job_worker.rs index df55c604..d6f2cbc6 100644 --- a/src/worker/job_worker.rs +++ b/src/worker/job_worker.rs @@ -2794,7 +2794,42 @@ impl JobWorker { .trim_end_matches('/'), uuid ); - if std::path::Path::new(&traced_path).exists() { + // ✅ V2: Check data integrity, not just file existence + let traced_dir = format!( + "{}/{}/traced_faces/", + crate::core::config::OUTPUT_DIR + .as_str() + .trim_end_matches('/'), + uuid + ); + let trace_complete = if std::path::Path::new(&traced_path).exists() { + // Check if traced_faces/ directory exists and has files + if std::path::Path::new(&traced_dir).exists() { + if let Ok(entries) = std::fs::read_dir(&traced_dir) { + let file_count = entries.count(); + if file_count > 0 { + info!("✅ Face trace already done for {}, {} files in traced_faces/", uuid, file_count); + true + } else { + warn!("⚠️ Face trace incomplete for {}: traced_faces/ is empty, re-running", uuid); + let _ = std::fs::remove_file(&traced_path); + false + } + } else { + warn!("⚠️ Face trace incomplete for {}: cannot read traced_faces/, re-running", uuid); + let _ = std::fs::remove_file(&traced_path); + false + } + } else { + warn!("⚠️ Face trace incomplete for {}: traced_faces/ not found, re-running", uuid); + let _ = std::fs::remove_file(&traced_path); + false + } + } else { + false + }; + + if trace_complete { info!("✅ Face trace already done for {}, skipping spawn", uuid); } else { // Fast-path for no-face videos: face.json reports no_faces, so