diff --git a/src/api/files.rs b/src/api/files.rs index 9aac40e4..b2f59491 100644 --- a/src/api/files.rs +++ b/src/api/files.rs @@ -1982,13 +1982,18 @@ async fn sync_file_status( let phase_completed = phase == "COMPLETED"; // 狀態判斷 - let new_status = if all_consistent && any_json_exists { + // Priority: phase completed > all_consistent > any_json_exists + let new_status = if phase_completed && any_json_exists { + // Phase marked completed in DB → trust it + "completed" + } else if all_consistent && any_json_exists { + // All processor JSONs consistent → completed "completed" } else if any_json_exists { - // 部分 JSON 存在或不一致 → 入庫中 + // Some JSONs exist but incomplete or inconsistent → scanning "scanning" } else { - // 無 JSON → 未開始 + // No JSONs → not started "registered" };