Files
StarAsh042 0cad26091a feat(startup): 接入 prestartup 启动期清理
ComfyUI 加载节点前先执行 prestartup 脚本,清掉上一轮的运行期产物。
2026-10-18 09:12:00 +08:00

25 lines
991 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""ComfyUI 启动钩子:清理上次运行留下的默认记录文件,保证每次启动都是干净的。
ComfyUI 在加载自定义节点之前,以“单文件模块”的方式执行本文件
(``main.py`` 的 ``execute_prestartup_script``,用 ``spec_from_file_location`` 加载),
此时节点目录还不在 ``sys.path`` 上,因此先把节点目录加进去,
再按包的形式导入 ``ra_core`` 复用清理实现(``ra_core/startup.py``)。
"""
import os
import sys
NODE_DIR = os.path.dirname(os.path.abspath(__file__))
if NODE_DIR not in sys.path:
sys.path.insert(0, NODE_DIR)
try:
from ra_core.startup import cleanup_default_runtime_files
_removed = cleanup_default_runtime_files()
except Exception as error: # 启动清理绝不能影响 ComfyUI 启动
print(f"[RollingArtist] 启动清理失败(已忽略): {error}")
else:
if _removed:
print("[RollingArtist] 已清理上次运行的记录文件: " + ", ".join(_removed))