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

Function fingerprint

cli/src/serve.rs:109–130  ·  view source on GitHub ↗

Cheap directory fingerprint: a rolling sum of file mtimes and sizes.

(dir: &Path)

Source from the content-addressed store, hash-verified

107
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
130}
131
132#[cfg(target_os = "macos")]
133fn open_url(url: &str) -> std::io::Result<()> {

Callers 1

spawn_watcherFunction · 0.85

Calls 1

walkFunction · 0.70

Tested by

no test coverage detected