From 66beafa52e2fffb082fe2bb79c702520b332c0bb Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Wed, 11 Nov 2026 20:28:56 -0500 Subject: [PATCH] Allow going back to an older version over the launcher's own Flatpak; bump to 0.19.2 (#1416) * Allow going back to an older version over the launcher's own Flatpak * Bump to 0.19.2 --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- crates/native/src/backend.rs | 2 +- crates/native/src/install.rs | 14 +++++++++++++- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 16e0e30a..08a95f39 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -272,7 +272,7 @@ checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56" [[package]] name = "artcraft-launcher" -version = "0.19.1" +version = "0.19.2" dependencies = [ "artcraft-launcher-core", "artcraft-launcher-native", @@ -298,7 +298,7 @@ dependencies = [ [[package]] name = "artcraft-launcher-core" -version = "0.19.1" +version = "0.19.2" dependencies = [ "base64 0.22.1", "ed25519-dalek", @@ -312,7 +312,7 @@ dependencies = [ [[package]] name = "artcraft-launcher-native" -version = "0.19.1" +version = "0.19.2" dependencies = [ "artcraft-launcher-core", "craft-update", @@ -336,7 +336,7 @@ dependencies = [ [[package]] name = "artcraft-launcher-ui-egui" -version = "0.19.1" +version = "0.19.2" dependencies = [ "artcraft-launcher-core", "craft-ui", @@ -356,7 +356,7 @@ dependencies = [ [[package]] name = "artcraft-launcher-web" -version = "0.19.1" +version = "0.19.2" dependencies = [ "artcraft-launcher-core", "artcraft-launcher-ui-egui", @@ -6355,7 +6355,7 @@ checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9" [[package]] name = "xtask" -version = "0.19.1" +version = "0.19.2" dependencies = [ "jiff", "semver", diff --git a/Cargo.toml b/Cargo.toml index bf23092a..034ef0d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ resolver = "3" members = ["crates/*", "apps/*", "xtask"] [workspace.package] -version = "0.19.1" +version = "0.19.2" edition = "2024" license = "MIT OR Apache-2.0" rust-version = "1.95" diff --git a/crates/native/src/backend.rs b/crates/native/src/backend.rs index 2092d459..ccee29d5 100644 --- a/crates/native/src/backend.rs +++ b/crates/native/src/backend.rs @@ -803,7 +803,7 @@ fn run_install( let InstallPlan { release, platform, asset, kind } = install_plan(app, latest, platform, options, (existing, record), Asking::Install)?; let http = http.ok_or("secure connections aren't available on this system")?; let track = options.versions.get(app.id).unwrap_or(&VersionTrack::Stable); - // Going back to a version chosen by name. A macOS bundle or a launcher AppImage keeps the old + // Going back to a version chosen by name. A macOS bundle, a launcher AppImage or Flatpak keeps the old // copy until the new one is in place. Otherwise the installed version's own package is found // first, so a downgrade that fails can put it back. Without it nothing changes. let keeps_old_copy = install::keeps_old_copy(kind, existing, record); diff --git a/crates/native/src/install.rs b/crates/native/src/install.rs index 82df509c..67d1f2d2 100644 --- a/crates/native/src/install.rs +++ b/crates/native/src/install.rs @@ -86,12 +86,16 @@ pub enum Downgrade<'a> { /// Whether going back over `existing` keeps the old copy until the new one is in place, the same /// way an update does. A macOS bundle is moved aside and moved back if the swap fails. An /// AppImage the launcher installed (`previous` records it) is renamed in whole, and the old file -/// is removed only after that. A tarball is left out: its `bin` and `share` swap one at a time. +/// is removed only after that. A Flatpak bundle over the launcher's own Flatpak (same bundle +/// origin) deploys the new commit before undeploying the old one, as an update does; a Flatpak +/// from a repository is left to that repository. A tarball is left out: its `bin` and `share` +/// swap one at a time. pub fn keeps_old_copy(kind: PackageKind, existing: Option<&Installed>, previous: Option<&Record>) -> bool { let source = existing.map(|inst| inst.source); match kind { PackageKind::Dmg => source == Some(InstallSource::MacApp), PackageKind::AppImage => source == Some(InstallSource::Launcher) && previous.is_some_and(|r| r.kind == PackageKind::AppImage), + PackageKind::Flatpak => existing.is_some_and(|inst| inst.source == InstallSource::Flatpak && !inst.externally_managed), _ => false, } } @@ -2889,6 +2893,14 @@ mod tests { assert!(!keeps_old_copy(PackageKind::AppImage, Some(&installed(InstallSource::AppImage)), Some(&appimage))); assert!(!keeps_old_copy(PackageKind::AppImage, Some(&portable), Some(&tarball))); assert!(!keeps_old_copy(PackageKind::TarGz, Some(&portable), Some(&tarball))); + // A Flatpak bundle over the launcher's own Flatpak keeps it; one from a repository doesn't. + let flatpak = installed(InstallSource::Flatpak); + let managed = Installed { externally_managed: true, ..installed(InstallSource::Flatpak) }; + assert!(keeps_old_copy(PackageKind::Flatpak, Some(&flatpak), None)); + assert!(downgrade_is_safe(keep, PackageKind::Flatpak, Some(&flatpak), None)); + assert!(!keeps_old_copy(PackageKind::Flatpak, Some(&managed), None)); + assert!(!keeps_old_copy(PackageKind::Flatpak, Some(&portable), None)); + assert!(!keeps_old_copy(PackageKind::Flatpak, None, None)); // Each way back fits one kind of install; anything else is refused. assert!(downgrade_is_safe(None, PackageKind::AppImage, Some(&portable), None)); assert!(downgrade_is_safe(keep, PackageKind::Dmg, Some(&mac), None));