Skip to main content

Module cache

Module cache 

Source
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§

CachePaths
The two files for one canonical root key in an application cache directory.
CacheStatus
What is known about one file in the cache directory.
ClearSummary
What one clear removed.
ContentInfo
The header facts that identify a content sidecar.
ContentStatus
What is known about the content sidecar beside a snapshot.
SnapshotInfo
The header facts that identify a snapshot.

Enums§

CacheScope
Which snapshots a cache-lifecycle request covers.
CacheState
What a path in the cache holds.
ContentState
What a content sidecar beside a snapshot holds.
LeftoverKind
Which of fdu’s own files a leftover is.
StaleReason
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.