MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / spawn

Method spawn

src/daemon/git_watch.rs:258–285  ·  view source on GitHub ↗

Registers the recently-seen projects and starts the backstop timer. Called once from `run_foreground_unix` after the engine is built. Safe to call on a disabled watcher (no-op).

(&self, global_db_path: Option<PathBuf>)

Source from the content-addressed store, hash-verified

256 /// Called once from `run_foreground_unix` after the engine is built. Safe to
257 /// call on a disabled watcher (no-op).
258 pub async fn spawn(&self, global_db_path: Option<PathBuf>) {
259 if !self.inner.enabled {
260 return;
261 }
262 // Enumerate recently-seen code projects (most-recent first, capped).
263 let window = 14 * 86_400;
264 let cap = self.inner.config.watch_max_projects;
265 let db = match global_db_path.as_deref() {
266 Some(path) => crate::global_db::GlobalDb::open_at(path).await,
267 None => crate::global_db::GlobalDb::open().await,
268 };
269 if let Some(db) = db {
270 let projects = db.code_projects_seen_within(window, cap).await;
271 for record in projects {
272 let root = PathBuf::from(&record.canonical_root);
273 if root.is_dir() {
274 self.ensure_watching(&root).await;
275 }
276 }
277 }
278
279 // Start the single backstop timer.
280 let watcher = self.clone();
281 let db_path = global_db_path.clone();
282 tokio::spawn(async move {
283 backstop::run(watcher, db_path).await;
284 });
285 }
286
287 /// Lazily starts watching `project_root` if not already watched and under
288 /// the project cap. Idempotent and cheap on the hot path (a map lookup).

Callers 10

mainFunction · 0.45
round_trip_with_timeoutFunction · 0.45
spawn_workerFunction · 0.45
installed_binary_versionFunction · 0.45
run_foreground_unixFunction · 0.45
start_with_timeoutsMethod · 0.45

Calls 3

ensure_watchingMethod · 0.80
runFunction · 0.70

Tested by 1