ProCreations's picture
download
raw
1.03 kB
#!/usr/bin/env python3
"""Validate this bundle: re-hash every file and compare to SHA256SUMS.json.
Usage: python3 validate_bundle.py (run from the bundle root). Exit 0 iff clean."""
import hashlib, json, os, sys
root = os.path.dirname(os.path.abspath(__file__))
man = json.load(open(os.path.join(root, "SHA256SUMS.json")))
SELF = {"SHA256SUMS.json", "MANIFEST_DIGEST.txt"}
bad, seen = [], set()
for rel, expect in man["files"].items():
p = os.path.join(root, rel)
seen.add(rel)
if not os.path.isfile(p):
bad.append(f"MISSING {rel}"); continue
got = hashlib.sha256(open(p, "rb").read()).hexdigest()
if got != expect:
bad.append(f"MISMATCH {rel}")
walked = [os.path.relpath(os.path.join(d, f), root).replace(os.sep, "/")
for d, _, fs in os.walk(root) for f in fs]
for e in walked:
if e not in seen and e not in SELF:
bad.append(f"EXTRA {e}")
print(f"checked {len(man['files'])} entries; problems: {len(bad)}")
for b in bad:
print(" ", b)
sys.exit(1 if bad else 0)

Xet Storage Details

Size:
1.03 kB
·
Xet hash:
b9cc8f5da8c4849b0aa10100d5d39c58f62fa31206258e41232e37eb57939811

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.