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

Function list_lifecycles

atomic-cli/src/commands/agent/lifecycle.rs:769–803  ·  view source on GitHub ↗
(dir: &Path)

Source from the content-addressed store, hash-verified

767}
768
769fn list_lifecycles(dir: &Path) -> Vec<ManagedLifecycle> {
770 let entries = match fs::read_dir(dir) {
771 Ok(entries) => entries,
772 Err(_) => return Vec::new(),
773 };
774
775 let mut lifecycles = Vec::new();
776 for entry in entries.flatten() {
777 let path = entry.path();
778 if path.extension().and_then(|e| e.to_str()) != Some("json") {
779 continue;
780 }
781 let Ok(data) = fs::read_to_string(&path) else {
782 continue;
783 };
784 let Ok(mut lifecycle) = serde_json::from_str::<ManagedLifecycle>(&data) else {
785 log::warn!("skipping unparseable lifecycle file {}", path.display());
786 continue;
787 };
788 if lifecycle.refusal.is_none() {
789 lifecycle.refusal = load_first_refusal(dir, &lifecycle.run_id)
790 .inspect_err(|error| {
791 log::warn!(
792 "could not read refusal for managed lifecycle '{}': {}",
793 lifecycle.run_id,
794 error,
795 );
796 })
797 .ok()
798 .flatten();
799 }
800 lifecycles.push(lifecycle);
801 }
802 lifecycles
803}
804
805fn cleanup_expired(dir: &Path, now: i64) {
806 let entries = match fs::read_dir(dir) {

Callers 2

runMethod · 0.85
list_by_stateFunction · 0.85

Calls 6

load_first_refusalFunction · 0.85
extensionMethod · 0.80
is_noneMethod · 0.80
pathMethod · 0.45
okMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected