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

Function list_active

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

Source from the content-addressed store, hash-verified

437}
438
439fn list_active(dir: &Path, now: i64) -> Vec<ManagedLifecycle> {
440 let entries = match fs::read_dir(dir) {
441 Ok(entries) => entries,
442 Err(_) => return Vec::new(),
443 };
444
445 let mut active = Vec::new();
446 for entry in entries.flatten() {
447 let path = entry.path();
448 if path.extension().and_then(|e| e.to_str()) != Some("json") {
449 continue;
450 }
451 let Ok(data) = fs::read_to_string(&path) else {
452 continue;
453 };
454 let Ok(lifecycle) = serde_json::from_str::<ManagedLifecycle>(&data) else {
455 log::warn!("skipping unparseable lifecycle file {}", path.display());
456 continue;
457 };
458 if !lifecycle.is_expired(now) {
459 active.push(lifecycle);
460 }
461 }
462 active
463}
464
465fn cleanup_expired(dir: &Path, now: i64) {
466 let entries = match fs::read_dir(dir) {

Calls 4

extensionMethod · 0.80
pathMethod · 0.45
is_expiredMethod · 0.45
pushMethod · 0.45