fix(repair): Codex 审查修正 — progress 完成判据加严 + load_progress 防御增强
1. 保存 progress 前重新 detect_issues,只有 empty_field 清零才记 finished (修复 L2/L1 空字段被检测但未修复仍写 finished 的问题) 2. load_progress 增加 AttributeError 捕获(防 JSON 非 dict 形态崩溃)
This commit is contained in:
+12
-3
@@ -80,7 +80,7 @@ def load_progress(path: Path) -> set[str]:
|
||||
try:
|
||||
data = json.loads(path.read_text(encoding="utf-8"))
|
||||
return set(data.get("finished_video_ids", []))
|
||||
except (json.JSONDecodeError, KeyError, TypeError):
|
||||
except (json.JSONDecodeError, KeyError, TypeError, AttributeError):
|
||||
logger.warning("progress 文件损坏,忽略: {}", path)
|
||||
return set()
|
||||
|
||||
@@ -390,9 +390,18 @@ async def main_async(args: argparse.Namespace) -> None:
|
||||
all_stats.append(stats)
|
||||
completed += 1
|
||||
|
||||
# 无 error 且非 dry_run 才记 finished
|
||||
# 修复后重新检测,关键 issue 清零才记 finished
|
||||
if stats["error"] is None and not args.dry_run:
|
||||
await save_progress(progress_path, progress_lock, vid)
|
||||
index = TreeIndex.load_json(str(tree_path))
|
||||
remaining = [i for i in detect_issues(index) if i.issue_type == "empty_field"]
|
||||
if not remaining:
|
||||
await save_progress(progress_path, progress_lock, vid)
|
||||
else:
|
||||
logger.warning(
|
||||
"[{}] 修复后仍有 {} 个 empty_field,不计入 finished",
|
||||
vid,
|
||||
len(remaining),
|
||||
)
|
||||
|
||||
# 进度日志
|
||||
if completed % 10 == 0:
|
||||
|
||||
Reference in New Issue
Block a user