Skip to content

Commit

Permalink
fix(cli): skip migrating updater config if not active (#8768)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored Feb 5, 2024
1 parent bd73ab0 commit baca704
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changes/fix-migrate-updater.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@tauri-apps/cli": patch:bug
"tauri-cli": patch:bug
---

Do not migrate updater configuration if the active flag is set to false.
47 changes: 45 additions & 2 deletions tooling/cli/src/migrate/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,20 @@ fn process_updater(
if let Some(mut updater) = tauri_config.remove("updater") {
if let Some(updater) = updater.as_object_mut() {
updater.remove("dialog");
updater.remove("active");

// we only migrate the updater config if it's active
// since we now assume it's always active if the config object is set
// we also migrate if pubkey is set so we do not lose that information on the migration
// in this case, the user need to deal with the updater being inactive on their own
if updater
.remove("active")
.and_then(|a| a.as_bool())
.unwrap_or_default()
|| updater.get("pubkey").is_some()
{
plugins.insert("updater".into(), serde_json::to_value(updater)?);
}
}
plugins.insert("updater".into(), serde_json::to_value(updater)?);
}

Ok(())
Expand Down Expand Up @@ -711,6 +722,38 @@ mod test {
);
}

#[test]
fn skips_migrating_updater() {
let original = serde_json::json!({
"tauri": {
"updater": {
"active": false
}
}
});

let migrated = migrate(&original);
assert_eq!(migrated["plugins"]["updater"], serde_json::Value::Null);
}

#[test]
fn migrate_updater_pubkey() {
let original = serde_json::json!({
"tauri": {
"updater": {
"active": false,
"pubkey": "somekey"
}
}
});

let migrated = migrate(&original);
assert_eq!(
migrated["plugins"]["updater"]["pubkey"],
original["tauri"]["updater"]["pubkey"]
);
}

#[test]
fn migrate_csp_object() {
let original = serde_json::json!({
Expand Down

0 comments on commit baca704

Please sign in to comment.