Store account file version after migration

This commit is contained in:
AsamK 2022-08-28 15:40:23 +02:00
parent a25043e5d4
commit 9d534dc7bb

View file

@ -509,6 +509,8 @@ public class SignalAccount implements Closeable {
rootNode = jsonProcessor.readTree(Channels.newInputStream(fileChannel)); rootNode = jsonProcessor.readTree(Channels.newInputStream(fileChannel));
} }
var migratedLegacyConfig = false;
if (rootNode.hasNonNull("version")) { if (rootNode.hasNonNull("version")) {
var accountVersion = rootNode.get("version").asInt(1); var accountVersion = rootNode.get("version").asInt(1);
if (accountVersion > CURRENT_STORAGE_VERSION) { if (accountVersion > CURRENT_STORAGE_VERSION) {
@ -517,6 +519,9 @@ public class SignalAccount implements Closeable {
throw new IOException("Config file was created by a no longer supported older version!"); throw new IOException("Config file was created by a no longer supported older version!");
} }
previousStorageVersion = accountVersion; previousStorageVersion = accountVersion;
if (accountVersion < CURRENT_STORAGE_VERSION) {
migratedLegacyConfig = true;
}
} }
number = Utils.getNotNullNode(rootNode, "username").asText(); number = Utils.getNotNullNode(rootNode, "username").asText();
@ -616,7 +621,6 @@ public class SignalAccount implements Closeable {
} }
} }
var migratedLegacyConfig = false;
final var legacySignalProtocolStore = rootNode.hasNonNull("axolotlStore") final var legacySignalProtocolStore = rootNode.hasNonNull("axolotlStore")
? jsonProcessor.convertValue(Utils.getNotNullNode(rootNode, "axolotlStore"), ? jsonProcessor.convertValue(Utils.getNotNullNode(rootNode, "axolotlStore"),
LegacyJsonSignalProtocolStore.class) LegacyJsonSignalProtocolStore.class)