Browse Source

migrate port to vault settings

Jan-Peter Klein 1 năm trước cách đây
mục cha
commit
2f657c7c14

+ 10 - 0
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":

+ 4 - 0
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;