diff --git a/crates/update/src/detect/windows.rs b/crates/update/src/detect/windows.rs index bbc5e615c..c377209f4 100644 --- a/crates/update/src/detect/windows.rs +++ b/crates/update/src/detect/windows.rs @@ -30,8 +30,11 @@ pub(crate) fn string_tables(listed: &[(winsafe::LANGID, winsafe::co::CP)]) -> Ve /// An MSI install found in the registry. pub struct MsiInstall { + /// The product code, the registry key name under the uninstall list. pub product_code: String, + /// The version the entry reports, when it has a readable one. pub version: Option, + /// The app's executable in the install folder, when it can be found. pub exe: Option, } @@ -95,6 +98,7 @@ fn exe_path(app: &App, location: Option) -> Option { exe_candidates(app, location.as_deref(), &roots).into_iter().find(|p| p.exists()) } +/// The newest MSI install of `app` registered with the Windows Installer, if any. pub fn detect(app: &App) -> Option { let m = msi_installs(app).into_iter().next()?; Some(Installed { diff --git a/crates/update/src/install/windows.rs b/crates/update/src/install/windows.rs index 6061e0a61..3bbd0489e 100644 --- a/crates/update/src/install/windows.rs +++ b/crates/update/src/install/windows.rs @@ -79,6 +79,8 @@ pub fn remove_product(product_code: &str, log: &Path) -> Result<(), String> { explain(status.code()).map_err(|e| format!("{e}. Its log is at {}", log.display())) } +/// Uninstalls every MSI install of `app` registered with the Windows Installer, one at a time, with a +/// progress window and no restart. Fails when none is registered. pub fn uninstall_msi(app: &App, stop: &Stop, phase: &mut dyn FnMut(JobPhase)) -> Result<(), String> { let installs = crate::detect::windows::msi_installs(app); if installs.is_empty() { diff --git a/crates/update/src/self_update/detect.rs b/crates/update/src/self_update/detect.rs index 5268ec3d7..af85b09bd 100644 --- a/crates/update/src/self_update/detect.rs +++ b/crates/update/src/self_update/detect.rs @@ -2,7 +2,9 @@ #[cfg(windows)] use super::helper::is_own_executable; -use super::{App, Install, PackageKind, Path, PathBuf, Paths, Platform, Release, Version, pick_asset, process, version}; +use super::{App, Install, Path, PathBuf, Paths, Platform, Release, Version, pick_asset, version}; +#[cfg(target_os = "linux")] +use super::{PackageKind, process}; /// Makes an installed copy believe it's this version, to try the self-update against the current /// release. The restart helper drops it, so it lasts one run. diff --git a/crates/update/src/self_update/helper.rs b/crates/update/src/self_update/helper.rs index 2da10894b..61aa31b0b 100644 --- a/crates/update/src/self_update/helper.rs +++ b/crates/update/src/self_update/helper.rs @@ -8,7 +8,7 @@ use super::replace::is_plain_file; use super::replace::{mark_installed, unmark_unless_scheduled}; use super::{App, OsString, Path, PathBuf, Paths, Version, install, version}; #[cfg(windows)] -use super::{Install, Release, Restart, process, update}; +use super::{Install, Release, Restart, process}; /// The first argument of the Windows update helper: a copy of this program that finishes an /// update once the launcher has exited (see [`finish`]). diff --git a/crates/update/src/self_update/replace.rs b/crates/update/src/self_update/replace.rs index ef159af38..4665253f0 100644 --- a/crates/update/src/self_update/replace.rs +++ b/crates/update/src/self_update/replace.rs @@ -1,10 +1,16 @@ //! Swapping the running launcher for a new copy: AppImage, standalone tarball and release tree. +#[cfg(unix)] +use super::App; use super::detect::marker; #[cfg(unix)] use super::detect::prefix_with_share; -use super::helper::{done_file, failure_file, read_record}; -use super::{App, Path, PathBuf, Paths, Release, install}; +#[cfg(not(windows))] +use super::helper::read_record; +use super::helper::{done_file, failure_file}; +use super::{Path, Paths, Release}; +#[cfg(not(windows))] +use super::{PathBuf, install}; /// Records `release` as just installed, so it isn't offered again for [`super::detect::JUST_UPDATED_FOR`]: its /// tag, the time, and the version it installs. The outcome records of an earlier update are