INNER CODE UNIT · Python

input_fingerprint

varunsalian/debrify · tool/webdav_memory_stress/run.py:61

def input_fingerprint(context=None):
    """Hash each file once; a build context is the authoritative copied input."""
    digest = hashlib.sha256()
    inputs = [(str((HERE / name).relative_to(ROOT)), name) for name in BUILD_FILES]
    inputs += [(f"lib/{name}", f"lib/{name}") for name in SOURCES]
    hashes = {}
    for repository_name, context_name in inputs:
        path = ROOT / repository_name if context is None else context / context_name
        contents = path.read_bytes()
        digest.update(repository_name.encode())
        digest.update(b"\0")
        digest.update(contents)
        digest.update(b"\0")
        hashes[repository_name] = hashlib.sha256(contents).hexdigest()
    return {
        "inputDigest": digest.hexdigest(),
        "sourceSha256": {name: hashes[f"lib/{name}"] for name in SOURCES},
        "workerSha256": hashes[str((HERE / "worker.dart").relative_to(ROOT))],

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…