Skip to content

Commit 5fde93d

Browse files
committed
feat: reduce update check cache to 4 hours and display notification in stats output
1 parent 4ad33c9 commit 5fde93d

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/cli/stats.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,11 @@ fn run_default(store: &Store) -> Result<()> {
285285
);
286286
}
287287

288+
// Update Notification (4h cache)
289+
if let Some(latest) = crate::guard::update::check() {
290+
crate::guard::update::print_notification(&latest);
291+
}
292+
288293
println!();
289294
Ok(())
290295
}

src/guard/update.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ pub fn get_status() -> Status {
3232
.unwrap_or_default()
3333
.as_secs();
3434

35-
// Try to get latest version from cache or fetch it
35+
// Try to get latest version from cache or fetch it (Cache: 4 hours)
3636
let latest = if let Ok(content) = fs::read_to_string(&cache_path)
3737
&& let Ok(cache) = serde_json::from_str::<UpdateCache>(&content)
38-
&& now < cache.last_checked + 86400
38+
&& now < cache.last_checked + 14400
3939
{
4040
Some(cache.latest_version)
4141
} else {

0 commit comments

Comments
 (0)