You've already forked FrameTour-RenderWorker
fix(cache): 解决缓存清理时删除正在使用的文件问题
- 添加文件锁定检查机制避免删除正在使用的缓存文件 - 实现基于文件名提取cache_key的锁定状态检测 - 在删除前验证锁文件是否存在以确保安全清理 - 添加调试日志记录跳过的锁定文件信息
This commit is contained in:
@@ -292,6 +292,14 @@ class MaterialCache:
|
|||||||
for file_info in cache_files:
|
for file_info in cache_files:
|
||||||
if total_size <= target_size:
|
if total_size <= target_size:
|
||||||
break
|
break
|
||||||
|
# 从文件名提取 cache_key,检查是否有锁(说明正在被使用)
|
||||||
|
filename = os.path.basename(file_info['path'])
|
||||||
|
cache_key = os.path.splitext(filename)[0]
|
||||||
|
lock_path = self._get_lock_path(cache_key)
|
||||||
|
if os.path.exists(lock_path):
|
||||||
|
# 该文件正在被其他任务使用,跳过删除
|
||||||
|
logger.debug(f"Cache cleanup: skipping locked file {filename}")
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
os.remove(file_info['path'])
|
os.remove(file_info['path'])
|
||||||
total_size -= file_info['size']
|
total_size -= file_info['size']
|
||||||
|
|||||||
Reference in New Issue
Block a user