Skip to main content

diff_against_walk

Function diff_against_walk 

Source
pub fn diff_against_walk(
    manifest: &mut Manifest,
    current_files: &[PathBuf],
) -> Diff
Expand description

Compare the manifest to the current filesystem state and produce a Diff.

The walked file set is supplied by the caller (typically via crate::walk::collect_files_with_options) so this function does no I/O for path discovery — only per-file stat and (on stat mismatch) content read for blake3 verification.

§Mutation of the manifest

When a file’s stat tuple changes but its blake3 hash still matches the manifest entry (the touch-without-content-change case), this function updates the entry’s (mtime, size, ino) in place. This is not a correctness step — the diff is the same with or without the update — but it short-circuits future diffs on the same touched file: the next call sees the new stat tuple, hits the cheap-path match, and skips the blake3 read.

§Robustness

Files that vanish between the walk and the per-file stat (rare race) are silently skipped; they will appear in deleted on the next diff. Permission errors are treated similarly. The function never fails — every call returns a Diff.