Fix second audit findings and restore crash detection dialog

This commit is contained in:
2026-02-27 22:48:43 +02:00
parent df8606251f
commit 1da69dd44e
21 changed files with 228 additions and 181 deletions

View File

@@ -762,8 +762,12 @@ pub fn version_is_newer(latest: &str, current: &str) -> bool {
}
}
// If all compared parts are equal, longer version wins (1.2.3 > 1.2)
latest_parts.len() > current_parts.len()
// If all compared parts are equal, only consider newer if extra parts are non-zero
// (e.g., 1.2.1 > 1.2, but 1.2.0 == 1.2)
if latest_parts.len() > current_parts.len() {
return latest_parts[current_parts.len()..].iter().any(|&p| p > 0);
}
false
}
/// Parse a version string into numeric parts.
@@ -781,13 +785,13 @@ fn parse_version_parts(version: &str) -> Vec<u64> {
/// Check if AppImageUpdate tool is available on the system.
pub fn has_appimage_update_tool() -> bool {
// Check that the binary exists and can be spawned (--help may return non-zero)
std::process::Command::new("AppImageUpdate")
.arg("--help")
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.status()
.map(|s| s.success())
.unwrap_or(false)
.is_ok()
}
/// Batch check: read update info from an AppImage and check for updates.
@@ -935,7 +939,8 @@ pub fn download_and_apply_update(
// Atomic rename temp -> target
if let Err(e) = fs::rename(&temp_path, appimage_path) {
// Try to restore backup on failure
// Clean up temp file and restore backup on failure
fs::remove_file(&temp_path).ok();
if let Some(ref backup) = backup_path {
fs::rename(backup, appimage_path).ok();
}