diff --git a/.changes/fix-updater-installer-args-deserialization.md b/.changes/fix-updater-installer-args-deserialization.md new file mode 100644 index 00000000..6456f65f --- /dev/null +++ b/.changes/fix-updater-installer-args-deserialization.md @@ -0,0 +1,5 @@ +--- +"updater": patch +--- + +Fix deserialization of `windows > installerArgs` config field. diff --git a/.changes/fix-updater-installmode.md b/.changes/fix-updater-installmode.md new file mode 100644 index 00000000..ac20ee7a --- /dev/null +++ b/.changes/fix-updater-installmode.md @@ -0,0 +1,5 @@ +--- +"updater": patch +--- + +On Windows, fallback to `passive` install mode when not defined in config. diff --git a/plugins/updater/src/config.rs b/plugins/updater/src/config.rs index aea6a547..6847363c 100644 --- a/plugins/updater/src/config.rs +++ b/plugins/updater/src/config.rs @@ -64,13 +64,29 @@ impl Default for WindowsUpdateInstallMode { #[serde(rename_all = "camelCase")] pub struct WindowsConfig { /// Additional arguments given to the NSIS or WiX installer. - #[serde(default, alias = "installer-args")] + #[serde( + default, + alias = "installer-args", + deserialize_with = "deserialize_os_string" + )] pub installer_args: Vec, - /// Updating mode, see [`WindowsUpdateInstallMode`] for more info. + /// Updating mode, defaults to `passive` mode. + /// + /// See [`WindowsUpdateInstallMode`] for more info. #[serde(default, alias = "install-mode")] pub install_mode: WindowsUpdateInstallMode, } +fn deserialize_os_string<'de, D>(deserializer: D) -> Result, D::Error> +where + D: Deserializer<'de>, +{ + Ok(Vec::::deserialize(deserializer)? + .into_iter() + .map(OsString::from) + .collect::>()) +} + /// Updater configuration. #[derive(Debug, Clone, Deserialize, Default)] #[serde(rename_all = "camelCase")] diff --git a/plugins/updater/src/lib.rs b/plugins/updater/src/lib.rs index 8c0ea2cb..e060827d 100644 --- a/plugins/updater/src/lib.rs +++ b/plugins/updater/src/lib.rs @@ -13,7 +13,7 @@ html_favicon_url = "https://github.com/tauri-apps/tauri/raw/dev/app-icon.png" )] -use std::ffi::{OsStr, OsString}; +use std::ffi::OsString; use tauri::{ plugin::{Builder as PluginBuilder, TauriPlugin}, @@ -136,21 +136,18 @@ impl Builder { pub fn installer_args(mut self, args: I) -> Self where I: IntoIterator, - S: AsRef, + S: Into, { - let args = args - .into_iter() - .map(|a| a.as_ref().to_os_string()) - .collect::>(); + let args = args.into_iter().map(|a| a.into()).collect::>(); self.installer_args.extend_from_slice(&args); self } pub fn installer_arg(mut self, arg: S) -> Self where - S: AsRef, + S: Into, { - self.installer_args.push(arg.as_ref().to_os_string()); + self.installer_args.push(arg.into()); self } diff --git a/plugins/updater/src/updater.rs b/plugins/updater/src/updater.rs index a77d0af5..52b33e21 100644 --- a/plugins/updater/src/updater.rs +++ b/plugins/updater/src/updater.rs @@ -176,21 +176,18 @@ impl UpdaterBuilder { pub fn installer_arg(mut self, arg: S) -> Self where - S: AsRef, + S: Into, { - self.installer_args.push(arg.as_ref().to_os_string()); + self.installer_args.push(arg.into()); self } pub fn installer_args(mut self, args: I) -> Self where I: IntoIterator, - S: AsRef, + S: Into, { - let args = args - .into_iter() - .map(|a| a.as_ref().to_os_string()) - .collect::>(); + let args = args.into_iter().map(|a| a.into()).collect::>(); self.installer_args.extend_from_slice(&args); self } @@ -543,6 +540,13 @@ impl Update { |p| format!("{p}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"), ); + let install_mode = self + .config + .windows + .as_ref() + .map(|w| w.install_mode.clone()) + .unwrap_or_default(); + for path in paths { let found_path = path?.path(); // we support 2 type of files exe & msi for now @@ -555,17 +559,11 @@ impl Update { installer_path.push("\""); let installer_args = [ - self.config - .windows - .as_ref() - .map(|w| { - w.install_mode - .nsis_args() - .iter() - .map(|a| OsStr::new(a)) - .collect::>() - }) - .unwrap_or_default(), + install_mode + .nsis_args() + .iter() + .map(OsStr::new) + .collect::>(), self.installer_args .iter() .map(|a| a.as_os_str()) @@ -600,17 +598,11 @@ impl Update { msi_path.push("\"\"\""); let installer_args = [ - self.config - .windows - .as_ref() - .map(|w| { - w.install_mode - .msiexec_args() - .iter() - .map(|a| OsStr::new(a)) - .collect::>() - }) - .unwrap_or_default(), + install_mode + .msiexec_args() + .iter() + .map(OsStr::new) + .collect::>(), self.installer_args .iter() .map(|a| a.as_os_str()) diff --git a/plugins/updater/tests/app-updater/tauri.conf.json b/plugins/updater/tests/app-updater/tauri.conf.json index 6eb919ef..4c891ab9 100644 --- a/plugins/updater/tests/app-updater/tauri.conf.json +++ b/plugins/updater/tests/app-updater/tauri.conf.json @@ -5,7 +5,8 @@ "endpoints": ["http://localhost:3007"], "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEUwNDRGMjkwRjg2MDhCRDAKUldUUWkyRDRrUEpFNEQ4SmdwcU5PaXl6R2ZRUUNvUnhIaVkwVUltV0NMaEx6VTkrWVhpT0ZqeEEK", "windows": { - "installMode": "quiet" + "installMode": "quiet", + "installerArgs": ["/NS"] } } },