feat: 文件夹批量处理引擎(后端)

- BatchWorker 单线程轮询 batch_jobs 表,处理 source=batch 的运行,
  与主调度器互不抢占(next_queued_run 排除 batch 来源)
- 直接读取用户所选文件夹下的视频逐个执行流水线,不上传到工作目录;
  中间态与产物落在视频旁同名文件夹,batch.done.json 完成标记去重
- 支持暂停/继续、失败容错(单视频失败不阻塞后续)、删除任务只清库
- 孤儿清理跳过 source=batch 运行,防止误删用户视频文件夹
- workflow_runs 新增 source 列(upload/batch),旧库自动迁移
This commit is contained in:
2026-08-23 16:25:09 +08:00
parent b16e0e9f3c
commit 711867e79f
10 changed files with 2056 additions and 9 deletions
+5
View File
@@ -82,6 +82,11 @@ class OrphanCleaner:
run = self.db.get_run(run_id)
if run is None:
continue
# 批量处理运行(source=batch)跳过清理:其产物在用户视频旁的同名
# 文件夹里,不在主存储目录下;_has_files 检查不到会误判为孤儿删除,
# 且 _remove_run 还会删除 input_uri 的父目录(用户的视频文件夹)。
if run.get("source") == "batch":
continue
if run["status"] != "COMPLETED":
continue
if not self._expired(run.get("updated_at")):