MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / walk

Function walk

cli/src/serve.rs:110–126  ·  view source on GitHub ↗
(dir: &Path, acc: &mut u64)

Source from the content-addressed store, hash-verified

108/// Cheap directory fingerprint: a rolling sum of file mtimes and sizes.
109fn fingerprint(dir: &Path) -> u64 {
110 fn walk(dir: &Path, acc: &mut u64) {
111 let Ok(entries) = std::fs::read_dir(dir) else { return };
112 for entry in entries.flatten() {
113 let path = entry.path();
114 if path.is_dir() {
115 walk(&path, acc);
116 } else if let Ok(meta) = entry.metadata() {
117 let mtime = meta
118 .modified()
119 .ok()
120 .and_then(|t| t.duration_since(std::time::UNIX_EPOCH).ok())
121 .map(|d| d.as_secs())
122 .unwrap_or(0);
123 *acc = acc.wrapping_add(mtime).wrapping_add(meta.len());
124 }
125 }
126 }
127 let mut acc = 0;
128 walk(dir, &mut acc);
129 acc

Callers 1

fingerprintFunction · 0.70

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected