Skip to content

Commit

Permalink
Fix/web interface manager get latest compatible version (#706)
Browse files Browse the repository at this point in the history
* Correctly check for none PREVIEW channel latest compatible version

The only working channel was the PREVIEW channel, since any other channel would have fetched the actual version of the preview and used this as the potential latest compatible version.
This was caused due to incorrectly checking if the preview version should be ignored.

* Remove PREVIEW version constant

* Consider versions of different channels

In case the current server version isn't compatible with the latest version of the selected webUI channel, versions of other channel should be considered depending on the selected channel.

E.g. PREVIEW is the latest available version and thus, any version of another channel is also compatible with the PREVIEW channel

* Restrict min compatible version to the bundled version

The oldest compatible version for a server is the bundled version, thus, any version that is older than the bundled one should not be considered compatible
  • Loading branch information
schroda authored Oct 8, 2023
1 parent 849acfc commit a449a01
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ object WebInterfaceManager {
private val logger = KotlinLogging.logger {}
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Default)

private const val WEBUI_PREVIEW_VERSION = "PREVIEW"
private const val LAST_WEBUI_UPDATE_CHECK_KEY = "lastWebUIUpdateCheckKey"

private val preferences = Preferences.userNodeForPackage(WebInterfaceManager::class.java)
Expand Down Expand Up @@ -479,15 +478,24 @@ object WebInterfaceManager {
?: throw Exception("Invalid mappingFile")
val minServerVersionNumber = extractVersion(minServerVersionString)

val ignorePreviewVersion =
!WebUIChannel.doesConfigChannelEqual(WebUIChannel.PREVIEW) && webUIVersion == WEBUI_PREVIEW_VERSION
if (ignorePreviewVersion) {
continue
} else {
if (!WebUIChannel.doesConfigChannelEqual(WebUIChannel.from(webUIVersion))) {
// allow only STABLE versions for STABLE channel
if (WebUIChannel.doesConfigChannelEqual(WebUIChannel.STABLE)) {
continue
}

// allow all versions for PREVIEW channel
}

if (webUIVersion == WebUIChannel.PREVIEW.name) {
webUIVersion = fetchPreviewVersion()
}

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

0 comments on commit a449a01

Please sign in to comment.