Expand description
XDG content-addressable cache with the cache-id integrity-check mechanism.
A snapdir cache is just a local content-addressable store (the same
sharded layout as a file:// store): objects live under
<cache_dir>/.objects/<h[0..3]>/<h[3..6]>/<h[6..9]>/<h[9..]> and manifests
under <cache_dir>/.manifests/<id…>. This module mirrors the cache-side
integrity machinery of the Bash oracle:
check_snapshot_integritymirrors_snapdir_check_integrity(snapdir~L1691): given a snapshot id and a cache directory, assert the manifest is present locally, then verify every file object referenced by the manifest hashes (BLAKE3) to the checksum it is filed under. This is the “verify a cached snapshot by its id” check at the heart ofcheckout/verify.verify_cachemirrorsverify-cache(snapdir~L1011): enumerate every object under.objects/*/*/*/*, recompute its hash, and compare the actual hash to the expected hash encoded by the object’s own sharded path (the path is the content address). Collect mismatches; whenpurgeis set, delete the corrupt objects.flush_cachemirrorsflush-cache(snapdir~L1061): empty the cache directory, idempotent on a missing dir.
Per the library-purity principle this module performs no terminal I/O and
reads no $HOME/XDG/environment for behavior. The cache directory is a
parameter; the CLI lane resolves ${XDG_CACHE_HOME:-$HOME/.cache}/snapdir.
Hashing is in-process via the Hasher abstraction (the shipped default is
BLAKE3); we never shell out to b3sum. The sharded path layout is reused
from crate::store (object_path/manifest_path); it is not
reimplemented here.
Structs§
- Cache
Report - Outcome of a whole-cache scan by
verify_cache.
Enums§
- Cache
Error - Errors the cache integrity machinery can surface.
Functions§
- check_
manifest_ integrity - Like
check_snapshot_integritybut for an already-loadedManifest. - check_
snapshot_ integrity - Verifies a cached snapshot by its id — mirrors
_snapdir_check_integrity. - flush_
cache - Empties the local cache — mirrors
snapdir flush-cache. - load_
cached_ manifest - Loads a cached manifest by snapshot
idfromcache_dir. - verify_
cache - Verifies every object in the cache — mirrors
snapdir verify-cache.