diff options
author | Linnea Gräf <nea@nea.moe> | 2024-12-23 02:34:47 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-12-23 02:34:47 +0100 |
commit | 084f8d2f172ddffad27ad6115a0d2add7bd8f2ee (patch) | |
tree | 7a4c82a5bf0728603de9573bdef2f8151754c2dd /src/main/kotlin | |
parent | f0285e44ed113bcf2a11b5d6635f6124deb7fc3b (diff) | |
download | LocalTransactionLedger-084f8d2f172ddffad27ad6115a0d2add7bd8f2ee.tar.gz LocalTransactionLedger-084f8d2f172ddffad27ad6115a0d2add7bd8f2ee.tar.bz2 LocalTransactionLedger-084f8d2f172ddffad27ad6115a0d2add7bd8f2ee.zip |
Diffstat (limited to 'src/main/kotlin')
-rw-r--r-- | src/main/kotlin/moe/nea/ledger/modules/UpdateChecker.kt | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/main/kotlin/moe/nea/ledger/modules/UpdateChecker.kt b/src/main/kotlin/moe/nea/ledger/modules/UpdateChecker.kt index 1d6e299..0d89ca1 100644 --- a/src/main/kotlin/moe/nea/ledger/modules/UpdateChecker.kt +++ b/src/main/kotlin/moe/nea/ledger/modules/UpdateChecker.kt @@ -1,5 +1,6 @@ package moe.nea.ledger.modules +import com.google.gson.JsonElement import com.google.gson.JsonPrimitive import moe.nea.ledger.DevUtil import moe.nea.ledger.LedgerLogger @@ -38,7 +39,25 @@ class UpdateChecker @Inject constructor( NightlyAwareGithubUpdateSource("nea89o", "LocalTransactionLedger"), if (DevUtil.isDevEnv) UpdateTarget { listOf() } else UpdateTarget.deleteAndSaveInTheSameFolder(UpdateChecker::class.java), - CurrentVersion.ofTag(BuildConfig.GIT_COMMIT), + object : CurrentVersion { + override fun display(): String { + return BuildConfig.VERSION + } + + override fun isOlderThan(element: JsonElement?): Boolean { + if (element !is JsonPrimitive || !element.isString) return true + val newHash = element.asString // TODO: change once i support non nightly update streams + val length = minOf(newHash.length, BuildConfig.GIT_COMMIT.length) + if (newHash.substring(0, length).equals(BuildConfig.GIT_COMMIT.substring(0, length), ignoreCase = true)) + return false + return true + } + + + override fun toString(): String { + return "{gitversion:${BuildConfig.GIT_COMMIT}, version:${BuildConfig.FULL_VERSION}}" + } + }, "ledger" ) @@ -112,7 +131,6 @@ class UpdateChecker @Inject constructor( fun informAboutUpdates(potentialUpdate: PotentialUpdate) { if (hasNotified) return hasNotified = true -// logger.printOut("Update: ${potentialUpdate}") if (!potentialUpdate.isUpdateAvailable) return logger.printOut( ChatComponentText("§aThere is a new update for LocalTransactionLedger. Click here to automatically download and install it.") |