Expand description
Inspecting and clearing the snapshot cache.
Snapshot files are named by a hash of their root, which keeps two trees from colliding but leaves a directory of opaque names with no way to answer “which tree is this?”. These functions read each file’s bounded header to recover that mapping, so the cache can be inspected and cleared without guesswork.
A file is one of fdu’s snapshots only when its contents begin with the snapshot magic; a name alone proves nothing. A snapshot this build cannot serve is still fdu’s: an older or newer format, another engine fingerprint, or a header this build cannot read is reported as stale and cleared like a current one. The engine fingerprint mixes in the crate version, so without that every release would strand every snapshot the one before it wrote.
Two more kinds of file here are fdu’s without being a snapshot in place: a staging file a killed writer never renamed, and a content sidecar whose snapshot is gone. Both are reported as leftovers, and clearing the directory reclaims them under rules that keep a clear from racing a live writer or discarding a sidecar a snapshot still wants. Anything else is reported as unrecognized and never deleted.
Structs§
- Cache
Paths - The two files for one canonical root key in an application cache directory.
- Cache
Status - What is known about one file in the cache directory.
- Clear
Summary - What one clear removed.
- Content
Info - The header facts that identify a content sidecar.
- Content
Status - What is known about the content sidecar beside a snapshot.
- Snapshot
Info - The header facts that identify a snapshot.
Enums§
- Cache
Scope - Which snapshots a cache-lifecycle request covers.
- Cache
State - What a path in the cache holds.
- Content
State - What a content sidecar beside a snapshot holds.
- Leftover
Kind - Which of fdu’s own files a leftover is.
- Stale
Reason - Why a snapshot fdu wrote cannot be served by this build.
Functions§
- cache_
status - Read one cache file’s status without materializing its index.
- clear_
all_ caches - Remove every fdu snapshot in a cache directory, current or stale, and reclaim the files fdu left behind, leaving anything else alone.
- clear_
cache - Remove one snapshot, current or stale, with its content sidecar.
- list_
caches - Enumerate every entry in the cache directory.