feat: implement Re-scan API (partial)

實現內容:
1. 新增 ReScanRequest 和 ReScanResponse 結構體
2. 實現 re_scan API 函數
3. 添加路由 POST /api/v1/re-scan
4. 修改 process_register_command 添加 auto_pipeline_override 支持

測試結果:
- ✅ Re-scan API 可用
- ✅ Command 創建成功
- ✅ Force unregister 正確執行
- ❌ Monitor Job 未自動創建(需要進一步修復)

已知問題:
- register_single_file 在 force unregister 後仍返回 already_exists=true
- 導致 auto_pipeline 條件判斷失敗

下一步:
- 修改 register_single_file 修復 already_exists 標志
- 或在 process_register_command 中添加 force_unregister_executed 標志
This commit is contained in:
Accusys
2026-09-27 14:29:23 +08:00
parent 9cd3e20e48
commit ecb209633a
3 changed files with 240 additions and 4 deletions
+12 -4
View File
@@ -530,11 +530,16 @@ impl JobWorker {
.get("force")
.and_then(|v| v.as_bool())
.unwrap_or(false);
let auto_pipeline_override = cmd
.payload
.get("auto_pipeline")
.and_then(|v| v.as_bool())
.unwrap_or(false);
let face_settings = cmd.payload.get("face_settings").cloned();
info!(
"[COMMAND_QUEUE] Registering file: {} (user_id={:?}, force={})",
file_path, user_id, force
"[COMMAND_QUEUE] Registering file: {} (user_id={:?}, force={}, auto_pipeline_override={})",
file_path, user_id, force, auto_pipeline_override
);
let resp = register_single_file(&self.db, file_path, user_id, content_hash, force).await;
@@ -543,8 +548,11 @@ impl JobWorker {
anyhow::bail!("Register failed: {}", resp.message);
}
if resp.success
&& !resp.already_exists
// Trigger auto-pipeline if:
// 1. auto_pipeline_override flag is set, OR
// 2. (force || !already_exists) AND file is video AND auto_pipeline is enabled globally
if (auto_pipeline_override || (force || !resp.already_exists))
&& resp.success
&& resp.file_type.as_deref() == Some("video")
&& crate::core::config::get_auto_pipeline_enabled()
{