mirror of
https://github.com/tauri-apps/tauri-plugin-updater.git
synced 2026-01-31 00:55:19 +01:00
feat(updater): add allowDowngrades option (#2726)
* feat(updater): add allowDowngrades option * Add change file for allow_downgrades feature * Update .changes/add-allow-downgrades.md Committed via a GitHub action: https://github.com/tauri-apps/plugins-workspace/actions/runs/15383066245 Co-authored-by: Legend-Master <Legend-Master@users.noreply.github.com>
This commit is contained in:
committed by
tauri-bot
parent
7c2f5d554a
commit
77dea9550b
4
dist-js/index.d.ts
vendored
4
dist-js/index.d.ts
vendored
@@ -17,6 +17,10 @@ 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 */
|
||||
interface DownloadOptions {
|
||||
|
||||
@@ -22,6 +22,10 @@ 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,6 +46,7 @@ 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 {
|
||||
@@ -63,6 +64,9 @@ 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?;
|
||||
|
||||
Reference in New Issue
Block a user