(dir: &Path)
| 688 | } |
| 689 | |
| 690 | fn list_lifecycles(dir: &Path) -> Vec<ManagedLifecycle> { |
| 691 | let entries = match fs::read_dir(dir) { |
| 692 | Ok(entries) => entries, |
| 693 | Err(_) => return Vec::new(), |
| 694 | }; |
| 695 | |
| 696 | let mut lifecycles = Vec::new(); |
| 697 | for entry in entries.flatten() { |
| 698 | let path = entry.path(); |
| 699 | if path.extension().and_then(|e| e.to_str()) != Some("json") { |
| 700 | continue; |
| 701 | } |
| 702 | let Ok(data) = fs::read_to_string(&path) else { |
| 703 | continue; |
| 704 | }; |
| 705 | let Ok(lifecycle) = serde_json::from_str::<ManagedLifecycle>(&data) else { |
| 706 | log::warn!("skipping unparseable lifecycle file {}", path.display()); |
| 707 | continue; |
| 708 | }; |
| 709 | lifecycles.push(lifecycle); |
| 710 | } |
| 711 | lifecycles |
| 712 | } |
| 713 | |
| 714 | fn list_by_state(dir: &Path, now: i64) -> (Vec<ManagedLifecycle>, Vec<ManagedLifecycle>) { |
| 715 | list_lifecycles(dir) |
no test coverage detected