pub fn file_age(path: &Path) -> DurationExpand description
How long ago the file was last written; zero when that cannot be read, so that a file whose age is unknown is never taken for an old one.
use majordomus_cli::lease::file_age;
use std::time::Duration;
let dir = tempfile::tempdir().unwrap();
let path = dir.path().join("server.json");
assert_eq!(file_age(&path), Duration::ZERO, "no file: no age");
std::fs::write(&path, "").unwrap();
assert!(file_age(&path) < Duration::from_secs(60), "just written");