Skip to content

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

fix(cache): snapshot cleanup candidates with os.stat on Windows

shan35204b7b9657647b
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a907336d..60de09fb 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -122,3 +122,5 @@ jobs:
test/services/test_controller_video.py
test/services/test_webui_task.py
test/services/test_webui_headless_task_actions.py
+ test/services/test_cache_manager.py
+ test/services/test_material_cache.py
diff --git a/app/services/cache_manager.py b/app/services/cache_manager.py
index 849ce6ab..d40c0e71 100644
--- a/app/services/cache_manager.py
+++ b/app/services/cache_manager.py
@@ -95,7 +95,9 @@ def _iter_video_cache_entries(include_temp: bool = False) -> Iterator[_VideoCach
# 不跟随符号链接,确保清理逻辑不会越过默认缓存目录边界。
if not entry.is_file(follow_symlinks=False):
continue
- stat_result = entry.stat(follow_symlinks=False)
+ # DirEntry.stat() reports st_dev/st_ino as 0 on Windows, which
+ # would never match the os.stat() identity check before deletion.
+ stat_result = os.stat(entry.path, follow_symlinks=False)
except OSError as exc:
logger.warning(
f"failed to inspect video cache file: file={entry.name}, error={exc}"
diff --git a/app/services/material_cache.py b/app/services/material_cache.py
index 4426ae0e..8b47fa60 100644
--- a/app/services/material_cache.py
+++ b/app/services/material_cache.py
@@ -452,7 +452,9 @@ def cleanup_expired_material_search_cache(
try:
if not entry.is_file(follow_symlinks=False):
continue
- expected = entry.stat(follow_symlinks=False)
+ # DirEntry.stat() reports st_dev/st_ino as 0 on Windows, which
+ # would never match the identity check in _is_same_cache_file().
+ expected = os.stat(entry.path, follow_symlinks=False)
cache_age = current_time - expected.st_mtime
if _CACHE_TEMP_FILE_PATTERN.fullmatch(entry.name):
# An active write may look future-dated after a clock