From 2f657c7c14f15e80c278b06386a4001394544f96 Mon Sep 17 00:00:00 2001 From: Jan-Peter Klein Date: Tue, 7 Nov 2023 12:42:07 +0100 Subject: [PATCH] migrate port to vault settings --- .../java/org/cryptomator/common/settings/Settings.java | 10 ++++++++++ .../org/cryptomator/common/settings/SettingsJson.java | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/org/cryptomator/common/settings/Settings.java b/src/main/java/org/cryptomator/common/settings/Settings.java index b8a872a98..13e3d32ec 100644 --- a/src/main/java/org/cryptomator/common/settings/Settings.java +++ b/src/main/java/org/cryptomator/common/settings/Settings.java @@ -106,6 +106,7 @@ public class Settings { this.directories.addAll(json.directories.stream().map(VaultSettings::new).toList()); migrateLegacySettings(json); + migratePortToVaultSettings(json); directories.addListener(this::somethingChanged); askedForUpdateCheck.addListener(this::somethingChanged); @@ -130,6 +131,15 @@ public class Settings { lastUpdateCheck.addListener(this::somethingChanged); } + @SuppressWarnings("deprecation") + private void migratePortToVaultSettings(SettingsJson json) { + if(json.port != 0){ + for (VaultSettings vaultSettings : directories) { + vaultSettings.port.set(json.port); + } + } + } + @SuppressWarnings("deprecation") private void migrateLegacySettings(SettingsJson json) { // implicit migration of 1.6.x legacy setting "preferredVolumeImpl": diff --git a/src/main/java/org/cryptomator/common/settings/SettingsJson.java b/src/main/java/org/cryptomator/common/settings/SettingsJson.java index d1c9137c5..cb7bcd534 100644 --- a/src/main/java/org/cryptomator/common/settings/SettingsJson.java +++ b/src/main/java/org/cryptomator/common/settings/SettingsJson.java @@ -46,6 +46,10 @@ class SettingsJson { @JsonProperty("numTrayNotifications") int numTrayNotifications = Settings.DEFAULT_NUM_TRAY_NOTIFICATIONS; + @Deprecated(since = "1.10.2") + @JsonProperty(value = "port", access = JsonProperty.Access.WRITE_ONLY) // WRITE_ONLY means value is "written" into the java object during deserialization. Upvote this: https://github.com/FasterXML/jackson-annotations/issues/233 + int port; + @JsonProperty("showMinimizeButton") boolean showMinimizeButton = Settings.DEFAULT_SHOW_MINIMIZE_BUTTON;