How purgatoryforcookies/file-checker works
Project type and purpose
• This is a CLI file‐checking tool written in Rust.
• Purpose: given two directories (“source” and “destination”), compute a Blake3 hash of each file in both, then report which source files are missing or altered in the destination.
File structure
• Top‐level files:
• Cargo.toml / Cargo.lock: Rust project descriptor and dependency lockfile
• src/main.rs: the CLI entry point
• src/scan.rs: directory scanning logic
• src/file.rs: file abstraction and hashing logic
• src/core.rs: comparison logic (comparing hash sets)
• A fixtures folder under src/__fixtures__ used for testing.
• CI configurations in .github/workflows.
• README.md, CHANGELOG.md for docs.
README for additional insights
• Describes three main steps: scan source & hash, scan destination & hash, compare.
• Writes a result.txt in the current working directory.
• Uses clap (or similar) via Cargo run with --source and --destination flags.
a. Main components
• CLI Parser (main.rs)
• Directory Scanner (scan.rs)
• Hasher (file.rs, Blake3 crate)
• Comparator (core.rs)
• Result Writer (core.rs or main.rs)
• File System (OS interface)
• External library: blake3
b. Relationships and interactions
• CLI Parser → invokes Directory Scanner twice (source & destination)
• Directory Scanner → yields File records to Hasher
• Hasher → produces HashSet for each directory
• Comparator → takes two HashSets, computes missing items
• Result Writer → writes missing‐file list to result.txt in working directory
c. Architectural patterns / design principles
• Layered pipeline: Input → Processing → Output
• Single Responsibility: each module handles one concern
• Dependency injection via function parameters
d. Relevant technologies / libraries
• Rust std::fs for file I/O
• blake3 crate for hashing
• clap or structopt (inferred) for argument parsing
• cargo for build/testing
Elements
• Clear labels: “CLI Parser”, “Scanner Module”, “Hasher Module”, “Comparator”, “Result Writer”
• CLI Parser → Scanner
• Scanner → Hasher
• Hasher → Comparator
• Comparator → Result Writer
• Rectangles for internal modules
• Rounded rectangles for external crates (blake3)
Detailed breakdown of components
• CLI Parser (main.rs)
• Parses --source / --destination
• Orchestrates scan, hash, compare, write
• Scanner (scan.rs)
• Recursively walks a directory
• Emits file paths
• Hasher (file.rs)
• Reads file content
• Computes blake3 hash
• Returns (path, hash) pair
• Comparator (core.rs)
• Builds two hash maps/sets
• Determines hashes present in source but missing in destination
• Formats the list of missing files
• Result Writer (core.rs or main.rs)
• Opens/creates result.txt
• Writes each missing file record