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/
This commit is contained in:
Accusys
2026-09-27 08:23:02 +08:00
parent 04d409d2e4
commit 0558cd7615
+36 -1
View File
@@ -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