Read cached version if still valid (< 24h old)
()
| 43 | |
| 44 | /// Read cached version if still valid (< 24h old) |
| 45 | fn read_cache() -> Option<String> { |
| 46 | let data = std::fs::read_to_string(cache_path()).ok()?; |
| 47 | let cache: UpdateCache = serde_json::from_str(&data).ok()?; |
| 48 | if now_secs().saturating_sub(cache.last_check) < CACHE_DURATION_SECS { |
| 49 | Some(cache.latest_version) |
| 50 | } else { |
| 51 | None |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | /// Write version to cache |
| 56 | fn write_cache(version: &str) { |
no test coverage detected