From d6bcf413360cc42f0cbf4f3eab9f2eb689568840 Mon Sep 17 00:00:00 2001 From: iomgaa Date: Thu, 9 Jul 2026 00:30:23 -0400 Subject: [PATCH] =?UTF-8?q?fix(repair):=20Codex=20=E5=AE=A1=E6=9F=A5?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20=E2=80=94=20progress=20=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E5=88=A4=E6=8D=AE=E5=8A=A0=E4=B8=A5=20+=20load=5Fprogress=20?= =?UTF-8?q?=E9=98=B2=E5=BE=A1=E5=A2=9E=E5=BC=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 保存 progress 前重新 detect_issues,只有 empty_field 清零才记 finished (修复 L2/L1 空字段被检测但未修复仍写 finished 的问题) 2. load_progress 增加 AttributeError 捕获(防 JSON 非 dict 形态崩溃) --- tools/repair_trees.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/repair_trees.py b/tools/repair_trees.py index c2690b7..dac5434 100644 --- a/tools/repair_trees.py +++ b/tools/repair_trees.py @@ -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: