fix(updater): detect stable releases from build metadata versions

This commit is contained in:
Tunglies
2026-09-21 19:11:30 +08:00
parent 81ce247ecc
commit 8982525fd2
3 changed files with 26 additions and 8 deletions
+13 -6
View File
@@ -101,15 +101,22 @@ impl SilentUpdater {
}
}
/// Compares numeric version components after stripping `v` and prerelease suffixes.
pub fn is_build_to_stable(current: &str, remote: &str) -> bool {
let Some((base, build)) = current.trim_start_matches('v').split_once('+') else {
return false;
};
!build.is_empty() && !base.contains('-') && base == remote.trim_start_matches('v')
}
/// Compares numeric version components after stripping version suffixes.
fn version_lte(a: &str, b: &str) -> bool {
let parse = |v: &str| -> Vec<u64> {
v.trim_start_matches('v')
.split(['-', '+'])
.next()
.unwrap_or("0")
.split('.')
.filter_map(|part| {
let numeric = part.split('-').next().unwrap_or("0");
numeric.parse::<u64>().ok()
})
.filter_map(|part| part.parse::<u64>().ok())
.collect()
};
@@ -152,7 +159,7 @@ impl SilentUpdater {
let cached_version = &meta.version;
if version_lte(cached_version, current_version) {
if !is_build_to_stable(current_version, cached_version) && version_lte(cached_version, current_version) {
logging!(
info,
Type::System,