diff --git a/src-tauri/src/core/updater.rs b/src-tauri/src/core/updater.rs index 657a35048..2cb56f9ea 100644 --- a/src-tauri/src/core/updater.rs +++ b/src-tauri/src/core/updater.rs @@ -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 { v.trim_start_matches('v') + .split(['-', '+']) + .next() + .unwrap_or("0") .split('.') - .filter_map(|part| { - let numeric = part.split('-').next().unwrap_or("0"); - numeric.parse::().ok() - }) + .filter_map(|part| part.parse::().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, diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 7dff71979..d8e9bfb53 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -44,7 +44,14 @@ mod app_init { let mut builder = builder .plugin(tauri_plugin_clash_verge_sysinfo::init()) .plugin(tauri_plugin_notification::init()) - .plugin(tauri_plugin_updater::Builder::new().build()) + .plugin( + tauri_plugin_updater::Builder::new() + .default_version_comparator(|current, release| { + release.version > current + || core::updater::is_build_to_stable(¤t.to_string(), &release.version.to_string()) + }) + .build(), + ) .plugin(tauri_plugin_clipboard_manager::init()) .plugin(tauri_plugin_process::init()) .plugin(tauri_plugin_global_shortcut::Builder::new().build()) diff --git a/src/services/update.ts b/src/services/update.ts index dccf1acf2..8fa8a58e8 100644 --- a/src/services/update.ts +++ b/src/services/update.ts @@ -78,7 +78,11 @@ export const checkUpdateSafe = async ( const remoteVersion = resolveRemoteVersion(result) const comparison = compareVersions(remoteVersion, localVersionNormalized) - if (comparison !== null && comparison <= 0) { + const isBuildToStable = + /^\d+\.\d+\.\d+\+[0-9A-Za-z.-]+$/.test(localVersionNormalized ?? '') && + remoteVersion === localVersionNormalized?.split('+')[0] + + if (comparison !== null && comparison <= 0 && !isBuildToStable) { try { await result.close() } catch (err) {