From a449a01a24db2a3160bddeb6edc051c4f6e2a615 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sun, 8 Oct 2023 02:20:09 +0200 Subject: [PATCH] Fix/web interface manager get latest compatible version (#706) * 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 --- .../server/util/WebInterfaceManager.kt | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt index 480e6290e..94eeea4b8 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt @@ -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) @@ -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 }