mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-20 21:20:42 +02:00
Merge commit from fork
This commit is contained in:
@@ -22,10 +22,6 @@ interface CheckOptions {
|
||||
* Target identifier for the running application. This is sent to the backend.
|
||||
*/
|
||||
target?: string
|
||||
/**
|
||||
* Allow downgrades to previous versions by not checking if the current version is greater than the available version.
|
||||
*/
|
||||
allowDowngrades?: boolean
|
||||
}
|
||||
|
||||
/** Options used when downloading an update */
|
||||
|
||||
@@ -46,7 +46,6 @@ pub(crate) async fn check<R: Runtime>(
|
||||
timeout: Option<u64>,
|
||||
proxy: Option<String>,
|
||||
target: Option<String>,
|
||||
allow_downgrades: Option<bool>,
|
||||
) -> Result<Option<Metadata>> {
|
||||
let mut builder = webview.updater_builder();
|
||||
if let Some(headers) = headers {
|
||||
@@ -64,9 +63,6 @@ pub(crate) async fn check<R: Runtime>(
|
||||
if let Some(target) = target {
|
||||
builder = builder.target(target);
|
||||
}
|
||||
if allow_downgrades.unwrap_or(false) {
|
||||
builder = builder.version_comparator(|current, update| update.version != current);
|
||||
}
|
||||
|
||||
let updater = builder.build()?;
|
||||
let update = updater.check().await?;
|
||||
|
||||
@@ -133,6 +133,19 @@ pub struct Config {
|
||||
///
|
||||
/// The default value of this flag is `false`.
|
||||
pub require_signed_version: bool,
|
||||
/// Allow the updater to install a release whose version is not newer than the
|
||||
/// currently running one, changing the version check from "must be newer" to
|
||||
/// "must be different".
|
||||
///
|
||||
/// Note that the updater only verifies the signature of the downloaded artifact,
|
||||
/// not the version advertised by the update endpoint, so enabling this removes the
|
||||
/// only guard against installing a previously released (and validly signed) version.
|
||||
///
|
||||
/// Ignored when the application sets a custom
|
||||
/// [`Builder::default_version_comparator`](crate::Builder::default_version_comparator).
|
||||
///
|
||||
/// The default value of this flag is `false`.
|
||||
pub allow_downgrades: bool,
|
||||
/// The Windows configuration for the updater.
|
||||
pub windows: Option<WindowsConfig>,
|
||||
}
|
||||
@@ -156,6 +169,8 @@ impl<'de> Deserialize<'de> for Config {
|
||||
pub pubkey: String,
|
||||
#[serde(default, alias = "require-signed-version")]
|
||||
pub require_signed_version: bool,
|
||||
#[serde(default, alias = "allow-downgrades")]
|
||||
pub allow_downgrades: bool,
|
||||
pub windows: Option<WindowsConfig>,
|
||||
}
|
||||
|
||||
@@ -174,6 +189,7 @@ impl<'de> Deserialize<'de> for Config {
|
||||
endpoints: config.endpoints,
|
||||
pubkey: config.pubkey,
|
||||
require_signed_version: config.require_signed_version,
|
||||
allow_downgrades: config.allow_downgrades,
|
||||
windows: config.windows,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -98,6 +98,11 @@ impl<R: Runtime, T: Manager<R>> UpdaterExt<R> for T {
|
||||
|
||||
builder.version_comparator = version_comparator.clone();
|
||||
|
||||
// a comparator set by the application takes precedence over the configuration
|
||||
if builder.version_comparator.is_none() && config.allow_downgrades {
|
||||
builder = builder.version_comparator(|current, update| update.version != current);
|
||||
}
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
|
||||
Reference in New Issue
Block a user