Skip to content

利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.

fix(webui): require a real file for completed history videos

Rudy Celeklibd9480353f11
diff --git a/test/services/test_webui_task_history.py b/test/services/test_webui_task_history.py
index aa6c5713..e7f4e09d 100644
--- a/test/services/test_webui_task_history.py
+++ b/test/services/test_webui_task_history.py
@@ -261,3 +261,11 @@ def test_history_scan_skips_non_object_script_payload(tmp_path, payload):
assert len(history) == 1
assert history[0]["task_id"] == "broken-task"
assert history[0]["subject"] == "broken-task"
+
+
+def test_find_final_task_video_ignores_directories_and_broken_links(tmp_path):
+ (tmp_path / "final-1.mp4").mkdir()
+ (tmp_path / "final-2.mp4").symlink_to(tmp_path / "missing.mp4")
+ assert find_final_task_video(str(tmp_path)) == ""
+ (tmp_path / "final-3.mp4").touch()
+ assert find_final_task_video(str(tmp_path)) == str(tmp_path / "final-3.mp4")
diff --git a/webui/Main.py b/webui/Main.py
index aaa6d8a4..b66753b6 100644
--- a/webui/Main.py
+++ b/webui/Main.py
@@ -830,7 +830,7 @@ def _find_final_task_video(task_path: str) -> str:
candidates = []
for file_name in files:
match = _FINAL_VIDEO_PATTERN.fullmatch(file_name)
- if match:
+ if match and os.path.isfile(os.path.join(task_path, file_name)):
candidates.append((int(match.group("index")), file_name))
if not candidates: