mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-29 12:06:01 +02:00
fix(updater): fallback to passive mode & fix installerArgs deserialzation (#1051)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"updater": patch
|
||||
---
|
||||
|
||||
Fix deserialization of `windows > installerArgs` config field.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"updater": patch
|
||||
---
|
||||
|
||||
On Windows, fallback to `passive` install mode when not defined in config.
|
||||
@@ -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<OsString>,
|
||||
/// 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<Vec<OsString>, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
Ok(Vec::<String>::deserialize(deserializer)?
|
||||
.into_iter()
|
||||
.map(OsString::from)
|
||||
.collect::<Vec<_>>())
|
||||
}
|
||||
|
||||
/// Updater configuration.
|
||||
#[derive(Debug, Clone, Deserialize, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
||||
@@ -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<I, S>(mut self, args: I) -> Self
|
||||
where
|
||||
I: IntoIterator<Item = S>,
|
||||
S: AsRef<OsStr>,
|
||||
S: Into<OsString>,
|
||||
{
|
||||
let args = args
|
||||
.into_iter()
|
||||
.map(|a| a.as_ref().to_os_string())
|
||||
.collect::<Vec<_>>();
|
||||
let args = args.into_iter().map(|a| a.into()).collect::<Vec<_>>();
|
||||
self.installer_args.extend_from_slice(&args);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn installer_arg<S>(mut self, arg: S) -> Self
|
||||
where
|
||||
S: AsRef<OsStr>,
|
||||
S: Into<OsString>,
|
||||
{
|
||||
self.installer_args.push(arg.as_ref().to_os_string());
|
||||
self.installer_args.push(arg.into());
|
||||
self
|
||||
}
|
||||
|
||||
|
||||
@@ -176,21 +176,18 @@ impl UpdaterBuilder {
|
||||
|
||||
pub fn installer_arg<S>(mut self, arg: S) -> Self
|
||||
where
|
||||
S: AsRef<OsStr>,
|
||||
S: Into<OsString>,
|
||||
{
|
||||
self.installer_args.push(arg.as_ref().to_os_string());
|
||||
self.installer_args.push(arg.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn installer_args<I, S>(mut self, args: I) -> Self
|
||||
where
|
||||
I: IntoIterator<Item = S>,
|
||||
S: AsRef<OsStr>,
|
||||
S: Into<OsString>,
|
||||
{
|
||||
let args = args
|
||||
.into_iter()
|
||||
.map(|a| a.as_ref().to_os_string())
|
||||
.collect::<Vec<_>>();
|
||||
let args = args.into_iter().map(|a| a.into()).collect::<Vec<_>>();
|
||||
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::<Vec<_>>()
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
install_mode
|
||||
.nsis_args()
|
||||
.iter()
|
||||
.map(OsStr::new)
|
||||
.collect::<Vec<_>>(),
|
||||
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::<Vec<_>>()
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
install_mode
|
||||
.msiexec_args()
|
||||
.iter()
|
||||
.map(OsStr::new)
|
||||
.collect::<Vec<_>>(),
|
||||
self.installer_args
|
||||
.iter()
|
||||
.map(|a| a.as_os_str())
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
"endpoints": ["http://localhost:3007"],
|
||||
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEUwNDRGMjkwRjg2MDhCRDAKUldUUWkyRDRrUEpFNEQ4SmdwcU5PaXl6R2ZRUUNvUnhIaVkwVUltV0NMaEx6VTkrWVhpT0ZqeEEK",
|
||||
"windows": {
|
||||
"installMode": "quiet"
|
||||
"installMode": "quiet",
|
||||
"installerArgs": ["/NS"]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user