Skip to content

Commit a6bba27

Browse files
feat(updater): add allowDowngrades option
1 parent 909bc1f commit a6bba27

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

plugins/updater/guest-js/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ interface CheckOptions {
2222
* Target identifier for the running application. This is sent to the backend.
2323
*/
2424
target?: string
25+
/**
26+
* Allow downgrades to previous versions by not checking if the current version is greater than the available version.
27+
*/
28+
allowDowngrades?: boolean
2529
}
2630

2731
/** Options used when downloading an update */

plugins/updater/src/commands.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub(crate) async fn check<R: Runtime>(
4646
timeout: Option<u64>,
4747
proxy: Option<String>,
4848
target: Option<String>,
49+
allow_downgrades: Option<bool>,
4950
) -> Result<Option<Metadata>> {
5051
let mut builder = webview.updater_builder();
5152
if let Some(headers) = headers {
@@ -63,6 +64,9 @@ pub(crate) async fn check<R: Runtime>(
6364
if let Some(target) = target {
6465
builder = builder.target(target);
6566
}
67+
if allow_downgrades.unwrap_or(false) {
68+
builder = builder.version_comparator(|current, update| update.version != current);
69+
}
6670

6771
let updater = builder.build()?;
6872
let update = updater.check().await?;

0 commit comments

Comments
 (0)