diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt | 14 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/Features.java | 2 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt index 8bb3b7268..19b77abf3 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt @@ -9,7 +9,7 @@ import com.google.gson.JsonPrimitive object ConfigUpdaterMigrator { val logger = LorenzLogger("ConfigMigration") - val configVersion = 8 + const val CONFIG_VERSION = 8 fun JsonElement.at(chain: List<String>, init: Boolean): JsonElement? { if (chain.isEmpty()) return this if (this !is JsonObject) return null @@ -39,8 +39,8 @@ object ConfigUpdaterMigrator { logger.log("Skipping move from $oldPath to $newPath ($since <= $oldVersion)") return } - if (since > configVersion) { - error("Illegally new version $since > $configVersion") + if (since > CONFIG_VERSION) { + error("Illegally new version $since > $CONFIG_VERSION") } if (since > oldVersion + 1) { logger.log("Skipping move from $oldPath to $newPath (will be done in another pass)") @@ -80,7 +80,7 @@ object ConfigUpdaterMigrator { } } - fun merge(a: JsonObject, b: JsonObject): Int { + private fun merge(a: JsonObject, b: JsonObject): Int { var c = 0 b.entrySet().forEach { val e = a.get(it.key) @@ -100,11 +100,11 @@ object ConfigUpdaterMigrator { fun fixConfig(config: JsonObject): JsonObject { val lV = (config.get("lastVersion") as? JsonPrimitive)?.asIntOrNull ?: -1 - if (lV > configVersion) { + if (lV > CONFIG_VERSION) { error("Cannot downgrade config") } - if (lV == configVersion) return config - return (lV until configVersion).fold(config) { acc, i -> + if (lV == CONFIG_VERSION) return config + return (lV until CONFIG_VERSION).fold(config) { acc, i -> logger.log("Starting config transformation from $i to ${i + 1}") val storage = acc.get("storage")?.asJsonObject val dynamicPrefix: Map<String, List<String>> = mapOf( diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java index ad7e5ab44..33d766fdf 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Features.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java @@ -153,6 +153,6 @@ public class Features extends Config { public Storage storage = new Storage(); @Expose - public int lastVersion = ConfigUpdaterMigrator.INSTANCE.getConfigVersion(); + public int lastVersion = ConfigUpdaterMigrator.CONFIG_VERSION; } |