MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / cleanup_expired

Function cleanup_expired

atomic-cli/src/commands/agent/lifecycle.rs:465–484  ·  view source on GitHub ↗
(dir: &Path, now: i64)

Source from the content-addressed store, hash-verified

463}
464
465fn cleanup_expired(dir: &Path, now: i64) {
466 let entries = match fs::read_dir(dir) {
467 Ok(entries) => entries,
468 Err(_) => return,
469 };
470 for entry in entries.flatten() {
471 let path = entry.path();
472 if path.extension().and_then(|e| e.to_str()) != Some("json") {
473 continue;
474 }
475 let expired = fs::read_to_string(&path)
476 .ok()
477 .and_then(|data| serde_json::from_str::<ManagedLifecycle>(&data).ok())
478 .map(|l| l.is_expired(now))
479 .unwrap_or(false);
480 if expired {
481 let _ = fs::remove_file(&path);
482 }
483 }
484}
485
486fn load_lifecycle(dir: &Path, run_id: &str) -> CliResult<Option<ManagedLifecycle>> {
487 validate_run_id(run_id)?;

Callers 2

runMethod · 0.85

Calls 3

extensionMethod · 0.80
pathMethod · 0.45
is_expiredMethod · 0.45