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

Function cleanup_expired

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

Source from the content-addressed store, hash-verified

803}
804
805fn cleanup_expired(dir: &Path, now: i64) {
806 let entries = match fs::read_dir(dir) {
807 Ok(entries) => entries,
808 Err(_) => return,
809 };
810 for entry in entries.flatten() {
811 let path = entry.path();
812 if path.extension().and_then(|e| e.to_str()) != Some("json") {
813 continue;
814 }
815 let expired = fs::read_to_string(&path)
816 .ok()
817 .and_then(|data| serde_json::from_str::<ManagedLifecycle>(&data).ok())
818 .map(|l| l.is_expired(now))
819 .unwrap_or(false);
820 if expired {
821 if let Some(run_id) = path.file_stem().and_then(|stem| stem.to_str()) {
822 let _ = fs::remove_file(lifecycle_refusal_path(dir, run_id));
823 }
824 let _ = fs::remove_file(&path);
825 }
826 }
827}
828
829fn list_by_state(dir: &Path, now: i64) -> (Vec<ManagedLifecycle>, Vec<ManagedLifecycle>) {
830 list_lifecycles(dir)

Callers

nothing calls this directly

Calls 5

lifecycle_refusal_pathFunction · 0.85
extensionMethod · 0.80
pathMethod · 0.45
okMethod · 0.45
is_expiredMethod · 0.45

Tested by

no test coverage detected