fix: 插件加载失败计入统计 — LOAD_FAILURES + 合并fail_details
This commit is contained in:
@@ -57,19 +57,25 @@ async def plugin_stats(req):
|
||||
total = len(ps.plugin_info) if ps else 0
|
||||
loaded = sum(1 for n, info in ps.plugin_info.items() if n in ps.plugins) if ps else 0
|
||||
disabled = total - loaded
|
||||
# 启动失败: 插件目录存在但未成功加载 + 导入失败记录
|
||||
# 合并: 导入失败 + 加载失败
|
||||
from services.plugin_service import LOAD_FAILURES
|
||||
failed = len(_IMPORT_FAILS)
|
||||
fail_details = dict(_IMPORT_FAILS)
|
||||
for name, reason in LOAD_FAILURES.items():
|
||||
if name not in fail_details:
|
||||
fail_details[name] = reason
|
||||
failed += 1
|
||||
if ps:
|
||||
for name, info in ps.plugin_info.items():
|
||||
if getattr(info, "error_count", 0) > 0 and name not in _IMPORT_FAILS:
|
||||
if getattr(info, "error_count", 0) > 0 and name not in fail_details:
|
||||
fail_details[name] = f"启动失败 (错误数: {info.error_count})"
|
||||
failed += 1
|
||||
_IMPORT_FAILS[name] = f"启动失败 (错误数: {info.error_count})"
|
||||
return web.json_response({
|
||||
"total": total,
|
||||
"loaded": loaded,
|
||||
"disabled": max(0, disabled),
|
||||
"failed": failed,
|
||||
"fail_details": dict(_IMPORT_FAILS),
|
||||
"fail_details": fail_details,
|
||||
})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user