from pathlib import Path import hashlib root = Path(__file__).resolve().parents[1] checksum = root / "metadata" / "checksums.sha256" errors = [] for line in checksum.read_text(encoding="utf-8").splitlines(): if not line.strip(): continue expected, rel = line.split(" ", 1) path = root / rel h = hashlib.sha256() with path.open("rb") as f: for chunk in iter(lambda: f.read(8 * 1024 * 1024), b""): h.update(chunk) actual = h.hexdigest() if actual != expected: errors.append((rel, expected, actual)) if errors: for rel, expected, actual in errors: print(f"MISMATCH {rel}: expected {expected}, got {actual}") raise SystemExit(1) print("All checksums OK.")