mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-08-22 08:43:37 +08:00
fix(monitor): 消除探测饿死与重试饥饿导致的跨目录连坐 (#6291)
This commit is contained in:
@@ -15,17 +15,17 @@ def count_directory_entries(directory: Path, max_check: int = 10000) -> Tuple[in
|
||||
:param max_check: 最大检查文件数量,避免长时间阻塞
|
||||
:return: (文件数量, 目录数量)
|
||||
"""
|
||||
file_count = 0
|
||||
dir_count = 0
|
||||
try:
|
||||
for _, dirs, files in os.walk(str(directory)):
|
||||
file_count += len(files)
|
||||
dir_count += len(dirs)
|
||||
if file_count > max_check:
|
||||
break
|
||||
# 走可强杀的子进程:挂载挂死时 os.walk 永不返回,会把启动重试的
|
||||
# 恢复动作永久钉死,进而饿死其他健康目录的待重试项
|
||||
# 延迟导入:filemanager 包的 __init__ 会拖入整条 chain 依赖,
|
||||
# 模块级导入会破坏 monitor 包的轻量加载
|
||||
from app.modules.filemanager.fsproxy import fsproxy
|
||||
result = fsproxy.count_entries(directory, max_check=max_check)
|
||||
return result.get("file_count", 0), result.get("dir_count", 0)
|
||||
except Exception as err:
|
||||
logger.debug(f"统计目录规模失败: {err}")
|
||||
return file_count, dir_count
|
||||
return 0, 0
|
||||
|
||||
|
||||
def count_directory_files(directory: Path, max_check: int = 10000) -> int:
|
||||
|
||||
Reference in New Issue
Block a user