MCPcopy Create free account
hub / github.com/PerroEngine/Perro / scan_inner

Function scan_inner

perro_editor/res/scripts/assets/editor_file_watch.rs:55–75  ·  view source on GitHub ↗
(root: &Path, path: &Path, out: &mut Vec<FileSig>)

Source from the content-addressed store, hash-verified

53 });
54}
55
56pub fn take_project_scan(root: &Path) -> Option<ProjectScan> {
57 let key = root.to_string_lossy();
58 let jobs = PROJECT_SCAN_JOBS.get_or_init(|| Mutex::new(BTreeMap::new()));
59 let mut guard = jobs.lock().ok()?;
60 let job = guard.get_mut(key.as_ref())?;
61 let scan = job.ready.take()?;
62 // Job is fully consumed (not running, ready drained) -- drop the entry
63 // instead of leaving a spent placeholder in the map forever.
64 guard.remove(key.as_ref());
65 Some(scan)
66}
67
68/// Drops scan-job entries for any root other than `root`. The editor only
69/// ever polls one project root at a time, so entries from a previously
70/// opened project would otherwise sit in the map (with a background thread
71/// possibly still writing to them) for the rest of the process lifetime.
72/// Call on project open/switch.
73pub fn retain_project_scan_job(root: &Path) {
74 let key = root.to_string_lossy().to_string();
75 let jobs = PROJECT_SCAN_JOBS.get_or_init(|| Mutex::new(BTreeMap::new()));
76 if let Ok(mut guard) = jobs.lock() {
77 guard.retain(|existing_key, _| existing_key == &key);
78 }

Callers 1

scan_watch_pathFunction · 0.85

Calls 5

read_dirFunction · 0.85
sig_for_metaFunction · 0.85
rel_pathFunction · 0.70
pathMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected