From 29751ee939fc8d26df07e4da3ad7f5c2aa0926ba Mon Sep 17 00:00:00 2001 From: Fabian-Lars Date: Tue, 25 Jun 2024 03:12:57 +0200 Subject: [PATCH] fix(updater): Escape msi path string (#1495) * fix(updater): Escape msi path string * fmt --- .changes/fix-updater-msi-path.md | 5 +++++ plugins/notification/build.rs | 8 +++++++- plugins/updater/src/updater.rs | 7 ++++++- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .changes/fix-updater-msi-path.md diff --git a/.changes/fix-updater-msi-path.md b/.changes/fix-updater-msi-path.md new file mode 100644 index 00000000..1de8f8db --- /dev/null +++ b/.changes/fix-updater-msi-path.md @@ -0,0 +1,5 @@ +--- +"updater": patch +--- + +On Windows, escape the path to the downloaded msi updater to fix an issue causing the update to fail when the `productName` contained spaces. diff --git a/plugins/notification/build.rs b/plugins/notification/build.rs index 0274771f..e5b6ced3 100644 --- a/plugins/notification/build.rs +++ b/plugins/notification/build.rs @@ -2,7 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -const COMMANDS: &[&str] = &["notify", "request_permission", "is_permission_granted", "register_action_types", "register_listener"]; +const COMMANDS: &[&str] = &[ + "notify", + "request_permission", + "is_permission_granted", + "register_action_types", + "register_listener", +]; fn main() { if let Err(error) = tauri_plugin::Builder::new(COMMANDS) diff --git a/plugins/updater/src/updater.rs b/plugins/updater/src/updater.rs index f06e699a..239a92c7 100644 --- a/plugins/updater/src/updater.rs +++ b/plugins/updater/src/updater.rs @@ -582,6 +582,11 @@ impl Update { let (updater_type, path, _temp) = Self::extract(bytes)?; + let mut msi_path = std::ffi::OsString::new(); + msi_path.push("\""); + msi_path.push(&path); + msi_path.push("\""); + let install_mode = self.config.install_mode(); let installer_args: Vec<&OsStr> = match updater_type { WindowsUpdaterType::Nsis => install_mode @@ -592,7 +597,7 @@ impl Update { .chain(self.nsis_installer_args()) .chain(self.installer_args()) .collect(), - WindowsUpdaterType::Msi => [OsStr::new("/i"), path.as_os_str()] + WindowsUpdaterType::Msi => [OsStr::new("/i"), msi_path.as_os_str()] .into_iter() .chain(install_mode.msiexec_args().iter().map(OsStr::new)) .chain(once(OsStr::new("/promptrestart")))