migrate port to vault settings

This commit is contained in:
Jan-Peter Klein
2023-11-07 12:42:07 +01:00
parent ab9278a9fc
commit 2f657c7c14
2 changed files with 14 additions and 0 deletions

View File

@@ -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":

View File

@@ -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;