(version: &str)
| 57 | } |
| 58 | |
| 59 | async fn save_cache(version: &str) -> tokio::io::Result<()> { |
| 60 | if let Some(cache_path) = Self::get_cache_path() { |
| 61 | if let Some(parent) = cache_path.parent() { |
| 62 | fs::create_dir_all(parent).await?; |
| 63 | } |
| 64 | |
| 65 | let now = SystemTime::now() |
| 66 | .duration_since(SystemTime::UNIX_EPOCH) |
| 67 | .unwrap() |
| 68 | .as_secs(); |
| 69 | let content = format!("{now},{version}"); |
| 70 | fs::write(cache_path, content).await?; |
| 71 | } |
| 72 | Ok(()) |
| 73 | } |
| 74 | |
| 75 | fn get_cache_path() -> Option<PathBuf> { |
| 76 | match std::env::var_os("HOME") { |
nothing calls this directly
no outgoing calls
no test coverage detected