aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-12-23 02:34:47 +0100
committerLinnea Gräf <nea@nea.moe>2024-12-23 02:34:47 +0100
commit084f8d2f172ddffad27ad6115a0d2add7bd8f2ee (patch)
tree7a4c82a5bf0728603de9573bdef2f8151754c2dd /src
parentf0285e44ed113bcf2a11b5d6635f6124deb7fc3b (diff)
downloadLocalTransactionLedger-084f8d2f172ddffad27ad6115a0d2add7bd8f2ee.tar.gz
LocalTransactionLedger-084f8d2f172ddffad27ad6115a0d2add7bd8f2ee.tar.bz2
LocalTransactionLedger-084f8d2f172ddffad27ad6115a0d2add7bd8f2ee.zip
fix: Implement proper version checkHEADnightlymaster
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/moe/nea/ledger/modules/UpdateChecker.kt22
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.")