Skip to content

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

fix: avoid reserved Windows download names

Sushanth012b1c1ac588307
diff --git a/test/services/test_webui_task_history.py b/test/services/test_webui_task_history.py
index 56b33a82..5f140189 100644
--- a/test/services/test_webui_task_history.py
+++ b/test/services/test_webui_task_history.py
@@ -16,6 +16,7 @@ TASK_HISTORY_HELPERS = {
TASK_HISTORY_CONSTANTS = {
"_FINAL_VIDEO_PATTERN",
"_DOWNLOAD_FILENAME_INVALID_PATTERN",
+ "_WINDOWS_RESERVED_FILENAMES",
"VOICE_MODE_TTS",
"VOICE_MODE_UPLOAD",
"VOICE_MODE_NONE",
@@ -90,6 +91,12 @@ def test_build_video_download_name_handles_empty_and_long_subjects():
assert len(build_video_download_name("a" * 100, 1, 1)) == 84
+def test_build_video_download_name_avoids_windows_reserved_names():
+ assert build_video_download_name("CON", 1, 1) == "_CON.mp4"
+ assert build_video_download_name("aux.extra", 1, 1) == "_aux.extra.mp4"
+ assert build_video_download_name("lpt1", 1, 1) == "_lpt1.mp4"
+
+
def test_restore_requirements_block_missing_uploaded_files():
params = {
"video_source": "local",
diff --git a/webui/Main.py b/webui/Main.py
index c20dddbf..c092bdc8 100644
--- a/webui/Main.py
+++ b/webui/Main.py
@@ -138,6 +138,11 @@ _FINAL_VIDEO_PATTERN = re.compile(
re.IGNORECASE,
)
_DOWNLOAD_FILENAME_INVALID_PATTERN = re.compile(r'[<>:"/\\|?*\x00-\x1f]')
+_WINDOWS_RESERVED_FILENAMES = frozenset(
+ {"CON", "PRN", "AUX", "NUL"}
+ | {f"COM{number}" for number in range(1, 10)}
+ | {f"LPT{number}" for number in range(1, 10)}
+)
_RUNTIME_CONFIG_SECTIONS = {
"app": config.app,
"azure": config.azure,
@@ -990,6 +995,8 @@ def _build_video_download_name(subject, index, total):
safe_subject = re.sub(r"\s+", " ", safe_subject).strip(" .")[:80].rstrip(" .")
if not safe_subject:
safe_subject = "video"
+ if safe_subject.split(".", 1)[0].upper() in _WINDOWS_RESERVED_FILENAMES:
+ safe_subject = f"_{safe_subject}"
suffix = f"-{index}" if total > 1 else ""
return f"{safe_subject}{suffix}.mp4"