MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / digest_file

Function digest_file

atomic-cli/tests/it/git_import_cb9c_test.rs:193–201  ·  view source on GitHub ↗
(path: &Path)

Source from the content-addressed store, hash-verified

191/// bytes plus the byte length (empty digest when absent).
192#[allow(dead_code)]
193fn digest_file(path: &Path) -> String {
194 let bytes = fs::read(path).unwrap_or_default();
195 let mut hash: u64 = 0xcbf29ce484222325;
196 for byte in &bytes {
197 hash ^= *byte as u64;
198 hash = hash.wrapping_mul(0x100000001b3);
199 }
200 format!("{hash:016x}-{}", bytes.len())
201}
202
203/// Digest of every populated shelf workspace under the common
204/// `.atomic/working-copies` tree, including file names and bytes. Empty when

Calls 1

readFunction · 0.70

Tested by

no test coverage detected