Expand description
In-process filesystem walk producing a frozen-format Manifest.
This module reproduces the original snapdir-manifest generate behavior in
pure Rust, consuming the frozen manifest,
merkle and excludes APIs without
changing any of them. It walks a directory tree and emits one
ManifestEntry per file (F) and directory (D), computing per-file
content checksums with a Hasher and per-directory checksums/sizes with
[directory_checksum].
§Behaviors matched against the oracle
- Traversal mirrors
find/find -L: every directory becomes aDentry (path ending/) and every regular file directly inside it becomes anFentry. Directories are recorded even when empty. - Symlinks are followed by default (
FollowMode::Follow, the oracle’sfind -L): a symlink to a directory is reported as a directory and descended into, a symlink to a file as a file, inheriting the target’s type/permissions/size/checksum.FollowMode::NoFollow(plainfind) drops symlinks entirely — they appear as neitherDnorF. - Permissions are the octal mode bits, matching
stat -f '%A'(macOS) /stat -c '%a'(Linux): the low 12 bits ofst_moderendered in octal with no leading zero (e.g.755,644,700). - File size is the content byte length (
%z/%s). Directory size is the sum of its direct members’ sizes (files and subdirectories), excluding the directory’s ownstatsize — matching the oracle’s_snapdir_manifest_sum_linesover the direct children. - Excludes are applied via
ExcludeMatcheragainst the absolute path of each candidate directory and file, mirroring the oracle’sfind … | grep -E -v "$EXCLUDE"(the filter runs before the relative./rewrite). A%system%expansion forcesFollowMode::NoFollow; the caller resolves that viaexpand_excludes. - Paths are absolute under
PathMode::Absolute, or rewritten to a leading./underPathMode::Relative(the oracle’ssed -E "s| \.?${root_dir}| .|"). Directory paths always end with/. - Ordering is
sort -k5(byte-wise on the path), delegated toManifest’s own sort.
Per the library-purity principle this module reads the filesystem at the
given root path (that is its job) but reads no $HOME/config/environment
for behavior: the root, options, excludes and hasher all arrive as
parameters, and errors surface as the typed WalkError.
Structs§
- Walk
Options - Options controlling a
walk.
Enums§
- Path
Mode - Whether emitted paths are absolute or rewritten relative to the root.
- Walk
Error - Errors raised while walking the filesystem.
Functions§
- walk
- Walks the directory tree rooted at
root, producing aManifestthat matches the originalsnapdir-manifestoutput byte-for-byte for the same tree and checksum function. - walk_
with_ meter - Like
walk, but records hashing progress into an optionalMeter.