Skip to content

Commit d9cb54b

Browse files
authored
Compare webUI version with bundled webUI version (#969)
* Compare webUI version with bundled webUI version The bundled webUI version was incorrectly compared with the minimum server version. This worked until the latest release, because the bundled webUI version had a lower revision number than the server revision, however, with the latest release, it is now higher, resulting in no compatible webUI version to be found * Consider bundled webUI version only for default flavor * Add "isDefault" util function to WebUIFlavor
1 parent f738a16 commit d9cb54b

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ enum class WebUIFlavor(
136136
}
137137
}
138138

139+
fun WebUIFlavor.isDefault(): Boolean = this == WebUIFlavor.default
140+
139141
object WebInterfaceManager {
140142
private val logger = KotlinLogging.logger {}
141143
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
@@ -314,10 +316,7 @@ object WebInterfaceManager {
314316
// check if the bundled webUI version is a newer version than the current used version
315317
// this could be the case in case no compatible webUI version is available and a newer server version was installed
316318
val shouldUpdateToBundledVersion =
317-
flavor.uiName == WebUIFlavor.default.uiName && extractVersion(getLocalVersion()) <
318-
extractVersion(
319-
BuildConfig.WEBUI_TAG,
320-
)
319+
flavor.isDefault() && extractVersion(getLocalVersion()) < extractVersion(BuildConfig.WEBUI_TAG)
321320
if (shouldUpdateToBundledVersion) {
322321
log.debug { "update to bundled version \"${BuildConfig.WEBUI_TAG}\"" }
323322

@@ -375,7 +374,7 @@ object WebInterfaceManager {
375374
return
376375
}
377376

378-
if (flavor.uiName != WebUIFlavor.default.uiName) {
377+
if (!flavor.isDefault()) {
379378
log.warn { "fallback to default webUI \"${WebUIFlavor.default.uiName}\"" }
380379

381380
serverConfig.webUIFlavor.value = WebUIFlavor.default.uiName
@@ -613,11 +612,9 @@ object WebInterfaceManager {
613612
webUIVersion = fetchPreviewVersion(flavor)
614613
}
615614

616-
val isCompatibleVersion =
617-
minServerVersionNumber <= currentServerVersionNumber && minServerVersionNumber >=
618-
extractVersion(
619-
BuildConfig.WEBUI_TAG,
620-
)
615+
val isNewerThanBundled =
616+
!flavor.isDefault() || extractVersion(webUIVersion) >= extractVersion(BuildConfig.WEBUI_TAG)
617+
val isCompatibleVersion = minServerVersionNumber <= currentServerVersionNumber && isNewerThanBundled
621618
if (isCompatibleVersion) {
622619
return webUIVersion
623620
}

0 commit comments

Comments
 (0)