File size: 734 Bytes
438394c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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.")