Skip to content

Commit baca704

Browse files
authored
fix(cli): skip migrating updater config if not active (#8768)
1 parent bd73ab0 commit baca704

2 files changed

Lines changed: 51 additions & 2 deletions

File tree

.changes/fix-migrate-updater.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@tauri-apps/cli": patch:bug
3+
"tauri-cli": patch:bug
4+
---
5+
6+
Do not migrate updater configuration if the active flag is set to false.

tooling/cli/src/migrate/config.rs

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,20 @@ fn process_updater(
503503
if let Some(mut updater) = tauri_config.remove("updater") {
504504
if let Some(updater) = updater.as_object_mut() {
505505
updater.remove("dialog");
506-
updater.remove("active");
506+
507+
// we only migrate the updater config if it's active
508+
// since we now assume it's always active if the config object is set
509+
// we also migrate if pubkey is set so we do not lose that information on the migration
510+
// in this case, the user need to deal with the updater being inactive on their own
511+
if updater
512+
.remove("active")
513+
.and_then(|a| a.as_bool())
514+
.unwrap_or_default()
515+
|| updater.get("pubkey").is_some()
516+
{
517+
plugins.insert("updater".into(), serde_json::to_value(updater)?);
518+
}
507519
}
508-
plugins.insert("updater".into(), serde_json::to_value(updater)?);
509520
}
510521

511522
Ok(())
@@ -711,6 +722,38 @@ mod test {
711722
);
712723
}
713724

725+
#[test]
726+
fn skips_migrating_updater() {
727+
let original = serde_json::json!({
728+
"tauri": {
729+
"updater": {
730+
"active": false
731+
}
732+
}
733+
});
734+
735+
let migrated = migrate(&original);
736+
assert_eq!(migrated["plugins"]["updater"], serde_json::Value::Null);
737+
}
738+
739+
#[test]
740+
fn migrate_updater_pubkey() {
741+
let original = serde_json::json!({
742+
"tauri": {
743+
"updater": {
744+
"active": false,
745+
"pubkey": "somekey"
746+
}
747+
}
748+
});
749+
750+
let migrated = migrate(&original);
751+
assert_eq!(
752+
migrated["plugins"]["updater"]["pubkey"],
753+
original["tauri"]["updater"]["pubkey"]
754+
);
755+
}
756+
714757
#[test]
715758
fn migrate_csp_object() {
716759
let original = serde_json::json!({

0 commit comments

Comments
 (0)