Skip to content

Commit 149d003

Browse files
unhappychoiceclaude
andcommitted
fix: invalidate version cache when current version changes
Version check cache was only validated by time, causing stale update notifications when the application version changed. Now the cache is also invalidated when the current version doesn't match the cached current_version, ensuring accurate update checks. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent d1ebea1 commit 149d003

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/version/cache.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ impl VersionCache {
7070
pub fn is_cache_valid(entry: &VersionCacheEntry, frequency_hours: u64) -> bool {
7171
let now = Utc::now();
7272
let hours_since_check = (now - entry.last_checked).num_hours();
73-
hours_since_check < frequency_hours as i64
73+
let time_valid = hours_since_check < frequency_hours as i64;
74+
75+
// Also check if the current version matches
76+
let current_version = env!("CARGO_PKG_VERSION");
77+
let version_valid = entry.current_version == current_version;
78+
79+
time_valid && version_valid
7480
}
7581
}

tests/unit/version/checker_test.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ fn test_is_version_newer() {
2222
assert!(!VersionChecker::is_version_newer("1.2.2", "1.2.3"));
2323
assert!(!VersionChecker::is_version_newer("1.2", "1.2.0"));
2424
assert!(VersionChecker::is_version_newer("1.2.0", "1.2"));
25+
26+
// Test the specific case causing issues
27+
println!(
28+
"Testing 0.6.2 vs 0.6.2: {}",
29+
VersionChecker::is_version_newer("0.6.2", "0.6.2")
30+
);
31+
assert!(!VersionChecker::is_version_newer("0.6.2", "0.6.2"));
2532
}
2633

2734
#[test]

0 commit comments

Comments
 (0)