fix: handle null status in face_traced.json for no-face videos

Issue: Files with face_traced.json status=null and total_faces=0 stuck in PROCESSING forever

Root cause:
- ingestion_complete checks trace_status == 'no_faces' to skip TKG
- But some old files have status=null instead of 'no_faces'
- TKG check fails because no nodes for no-face videos

Solution:
- Check both status='no_faces' AND total_faces=0
- Skip TKG check for no-face videos (total_faces=0)
- Also update face_cluster_done to handle total_faces=0

Impact:
- Fixes stuck files with null status in face_traced.json
- Consistent with scan.rs fix (commit 0d11c601)

Affected: M4ProMini file 18173b62d80bf829910348fa1a6ddcf5
This commit is contained in:
Accusys
2026-10-08 09:41:51 +08:00
parent 06a099e159
commit d55d398832
+17 -9
View File
@@ -2029,26 +2029,33 @@ impl JobWorker {
let output_dir = crate::core::config::OUTPUT_DIR.to_string();
let traced_path = format!("{}/{}.face_traced.json", output_dir, uuid);
let trace_status = if std::path::Path::new(&traced_path).exists() {
let (trace_status, total_faces) = if std::path::Path::new(&traced_path).exists() {
if let Ok(content) = std::fs::read_to_string(&traced_path) {
if let Ok(traced_data) = serde_json::from_str::<serde_json::Value>(&content) {
traced_data
let status = traced_data
.get("status")
.and_then(|s| s.as_str())
.unwrap_or("")
.to_string()
.to_string();
let faces = traced_data
.get("total_faces")
.and_then(|v| v.as_i64())
.or_else(|| traced_data.get("total_faces").and_then(|v| v.as_u64()).map(|n| n as i64));
(status, faces)
} else {
"".to_string()
("".to_string(), None)
}
} else {
"".to_string()
("".to_string(), None)
}
} else {
"".to_string()
("".to_string(), None)
};
let trace_done: bool = if has_face {
if trace_status == "no_faces" {
// Case 1: explicit "no_faces" status
// Case 2: total_faces is 0 (no-face video with null status)
if trace_status == "no_faces" || total_faces == Some(0) {
true
} else if !traced_path.is_empty() && std::path::Path::new(&traced_path).exists() {
if let Ok(content) = std::fs::read_to_string(&traced_path) {
@@ -2079,7 +2086,7 @@ impl JobWorker {
};
// 3. TKG: face_track_nodes 有資料(Face TKG 必須有 face tracking 寫入)
let tkg_done: bool = if has_face && trace_status != "no_faces" {
let tkg_done: bool = if has_face && trace_status != "no_faces" && total_faces != Some(0) {
Self::is_tkg_done(pool, uuid).await
} else {
true
@@ -2087,7 +2094,8 @@ impl JobWorker {
// 4. Face Cluster: face_cluster.json 存在(有 face 時才需要)
let face_cluster_done: bool = if has_face {
if trace_status == "no_faces" {
// No-face video: either explicit status or total_faces=0
if trace_status == "no_faces" || total_faces == Some(0) {
// 直接寫入空的 face_cluster.json 讓 sync-status 能正確判斷
let cluster_path = format!("{}/{}.face_cluster.json", output_dir, uuid);
if !std::path::Path::new(&cluster_path).exists() {