Skip to content

Commit

Permalink
Compare webUI version with bundled webUI version (#969)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
schroda authored Jun 15, 2024
1 parent f738a16 commit d9cb54b
Showing 1 changed file with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ enum class WebUIFlavor(
}
}

fun WebUIFlavor.isDefault(): Boolean = this == WebUIFlavor.default

object WebInterfaceManager {
private val logger = KotlinLogging.logger {}
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
Expand Down Expand Up @@ -314,10 +316,7 @@ object WebInterfaceManager {
// check if the bundled webUI version is a newer version than the current used version
// this could be the case in case no compatible webUI version is available and a newer server version was installed
val shouldUpdateToBundledVersion =
flavor.uiName == WebUIFlavor.default.uiName && extractVersion(getLocalVersion()) <
extractVersion(
BuildConfig.WEBUI_TAG,
)
flavor.isDefault() && extractVersion(getLocalVersion()) < extractVersion(BuildConfig.WEBUI_TAG)
if (shouldUpdateToBundledVersion) {
log.debug { "update to bundled version \"${BuildConfig.WEBUI_TAG}\"" }

Expand Down Expand Up @@ -375,7 +374,7 @@ object WebInterfaceManager {
return
}

if (flavor.uiName != WebUIFlavor.default.uiName) {
if (!flavor.isDefault()) {
log.warn { "fallback to default webUI \"${WebUIFlavor.default.uiName}\"" }

serverConfig.webUIFlavor.value = WebUIFlavor.default.uiName
Expand Down Expand Up @@ -613,11 +612,9 @@ object WebInterfaceManager {
webUIVersion = fetchPreviewVersion(flavor)
}

val isCompatibleVersion =
minServerVersionNumber <= currentServerVersionNumber && minServerVersionNumber >=
extractVersion(
BuildConfig.WEBUI_TAG,
)
val isNewerThanBundled =
!flavor.isDefault() || extractVersion(webUIVersion) >= extractVersion(BuildConfig.WEBUI_TAG)
val isCompatibleVersion = minServerVersionNumber <= currentServerVersionNumber && isNewerThanBundled
if (isCompatibleVersion) {
return webUIVersion
}
Expand Down

0 comments on commit d9cb54b

Please sign in to comment.