pub fn check_snapshot_integrity(
cache_dir: &Path,
id: &str,
hasher: &dyn Hasher,
) -> Result<(), CacheError>Expand description
Verifies a cached snapshot by its id — mirrors _snapdir_check_integrity.
First asserts the manifest for id is present locally (loading it from
<cache_dir>/.manifests/<id…>), then, for every file entry of the
manifest (directory entries — whose path ends / — are excluded, exactly as
the oracle’s grep -v "/$"), verifies that the cached object at its sharded
path hashes via hasher to the checksum it is filed under (column 3 of the
manifest line, i.e. the object’s content address).
The oracle pipes checksum path pairs into b3sum --check; this reproduces
that check in-process. The first corrupt or missing object short-circuits
with an error, matching b3sum --check’s non-zero exit.
§Errors
CacheError::ManifestNotFoundif the snapshot’s manifest is absent.CacheError::ObjectNotFoundif a referenced file object is missing.CacheError::Integrityif a cached object does not hash to its address.CacheError::Parse/CacheError::Ioon read/parse failure.