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

Function spawn_watcher

cli/src/serve.rs:94–106  ·  view source on GitHub ↗

Bump `version` whenever any file under `dir` changes. Mtime poll, no watcher dependency.

(dir: PathBuf, version: Arc<AtomicU64>)

Source from the content-addressed store, hash-verified

92
93/// Bump `version` whenever any file under `dir` changes. Mtime poll, no watcher dependency.
94fn spawn_watcher(dir: PathBuf, version: Arc<AtomicU64>) {
95 std::thread::spawn(move || {
96 let mut last = fingerprint(&dir);
97 loop {
98 std::thread::sleep(Duration::from_millis(400));
99 let now = fingerprint(&dir);
100 if now != last {
101 last = now;
102 version.fetch_add(1, Ordering::Relaxed);
103 }
104 }
105 });
106}
107
108/// Cheap directory fingerprint: a rolling sum of file mtimes and sizes.
109fn fingerprint(dir: &Path) -> u64 {

Callers 1

runFunction · 0.85

Calls 1

fingerprintFunction · 0.85

Tested by

no test coverage detected