Expand description
The length and hash of an index snapshot that a landing record keeps.
What:
The length and a 64-bit FNV-1a hash of a file’s bytes,
the evidence a landing record keeps about each index snapshot.
Why:
The index snapshots of a landing are written without a sync.
A power loss can leave one of them with fewer bytes than were written,
or with bytes that never reached the disk,
while the synced landing record and the moved branch survive.
Recovery installs the post-index as the real index,
so it compares the file with this evidence first and never installs a snapshot that differs.
FNV-1a is specified by its two constants and needs no dependency,
and it is stable across Rust versions and builds,
which std::hash::DefaultHasher is not;
it detects damage and is not meant to resist someone who edits the file on purpose.
Measured in a release build over a 521,631-byte index (5,000 entries): 0.38 ms per file.
In TS you’d write (pseudocode):
const digest = { length: bytes.length, fnv1a64: fnv1a64(bytes).toString(16).padStart(16, '0') };Structs§
- Content
Digest - What: The length and hash of one file’s bytes. Why: A truncated file differs in length and a file with unwritten or foreign bytes differs in hash.
Functions§
- digest_
bytes - What: The digest of in-memory bytes. Why: Tests pin the published FNV-1a vectors through it, and the file reader below must agree with it.
- digest_
file - What: The digest of a file’s current bytes, read in bounded chunks. Why: The landing records it for both snapshots after they are written, and recovery recomputes it from the pinned snapshot before installing anything.