Feature/webui update download failure do not immediately fallback to bundled version (#620)
* Return actual version for "PREVIEW" in "getLatestCompatibleVersion" In case "PREVIEW" is the latest available version, the function should immediately fetch the actual webUI version that is currently the latest released version. Thus, the function always returns a valid version and the preview version has not to be considered anymore at other places in the code * Ignore download failure in case local webUI version is valid In case the download failed e.g. due to internet connection issues, the server should only fall back to another version in case the local version is invalid or missing
This commit is contained in:
@@ -129,9 +129,23 @@ object WebInterfaceManager {
|
||||
* Tries to download the latest compatible version for the selected webUI and falls back to the default webUI in case of errors.
|
||||
*/
|
||||
private fun doInitialSetup() {
|
||||
val downloadSucceeded = downloadLatestCompatibleVersion()
|
||||
val isLocalWebUIValid = isLocalWebUIValid(applicationDirs.webUIRoot)
|
||||
|
||||
val fallbackToDefaultWebUI = !downloadSucceeded
|
||||
/**
|
||||
* Performs the download and returns if the download was successful.
|
||||
*
|
||||
* In case the download failed but the local webUI is valid the download is considered a success to prevent the fallback logic
|
||||
*/
|
||||
val doDownload = {
|
||||
try {
|
||||
downloadLatestCompatibleVersion()
|
||||
} catch (e: Exception) {
|
||||
false
|
||||
} || isLocalWebUIValid
|
||||
}
|
||||
|
||||
// download the latest compatible version for the current selected webUI
|
||||
val fallbackToDefaultWebUI = !doDownload()
|
||||
if (!fallbackToDefaultWebUI) {
|
||||
return
|
||||
}
|
||||
@@ -141,7 +155,7 @@ object WebInterfaceManager {
|
||||
|
||||
serverConfig.webUIFlavor = DEFAULT_WEB_UI
|
||||
|
||||
val fallbackToBundledVersion = !downloadLatestCompatibleVersion()
|
||||
val fallbackToBundledVersion = !doDownload()
|
||||
if (!fallbackToBundledVersion) {
|
||||
return
|
||||
}
|
||||
@@ -186,9 +200,8 @@ object WebInterfaceManager {
|
||||
private fun getDownloadUrlFor(version: String): String {
|
||||
val baseReleasesUrl = "${WebUI.WEBUI.repoUrl}/releases"
|
||||
val downloadSpecificVersionBaseUrl = "$baseReleasesUrl/download"
|
||||
val downloadLatestVersionBaseUrl = "$baseReleasesUrl/latest/download"
|
||||
|
||||
return if (version == webUIPreviewVersion) downloadLatestVersionBaseUrl else "$downloadSpecificVersionBaseUrl/$version"
|
||||
return "$downloadSpecificVersionBaseUrl/$version"
|
||||
}
|
||||
|
||||
private fun getLocalVersion(path: String): String {
|
||||
@@ -267,13 +280,15 @@ object WebInterfaceManager {
|
||||
|
||||
for (i in 0 until webUIToServerVersionMappings.length()) {
|
||||
val webUIToServerVersionEntry = webUIToServerVersionMappings.getJSONObject(i)
|
||||
val webUIVersion = webUIToServerVersionEntry.getString("uiVersion")
|
||||
var webUIVersion = webUIToServerVersionEntry.getString("uiVersion")
|
||||
val minServerVersionString = webUIToServerVersionEntry.getString("serverVersion")
|
||||
val minServerVersionNumber = extractVersion(minServerVersionString)
|
||||
|
||||
val ignorePreviewVersion = !WebUIChannel.doesConfigChannelEqual(WebUIChannel.PREVIEW) && webUIVersion == webUIPreviewVersion
|
||||
if (ignorePreviewVersion) {
|
||||
continue
|
||||
} else {
|
||||
webUIVersion = fetchPreviewVersion()
|
||||
}
|
||||
|
||||
val isCompatibleVersion = minServerVersionNumber <= currentServerVersionNumber
|
||||
@@ -286,17 +301,7 @@ object WebInterfaceManager {
|
||||
}
|
||||
|
||||
fun downloadLatestCompatibleVersion(retryCount: Int = 0): Boolean {
|
||||
val latestCompatibleVersion = try {
|
||||
val version = getLatestCompatibleVersion()
|
||||
|
||||
if (version == webUIPreviewVersion) {
|
||||
fetchPreviewVersion()
|
||||
} else {
|
||||
version
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
BuildConfig.WEBUI_TAG
|
||||
}
|
||||
val latestCompatibleVersion = getLatestCompatibleVersion()
|
||||
|
||||
val webUIZip = "${WebUI.WEBUI.baseFileName}-$latestCompatibleVersion.zip"
|
||||
val webUIZipPath = "$tmpDir/$webUIZip"
|
||||
@@ -385,13 +390,7 @@ object WebInterfaceManager {
|
||||
|
||||
fun isUpdateAvailable(currentVersion: String): Boolean {
|
||||
return try {
|
||||
val version = getLatestCompatibleVersion()
|
||||
val latestCompatibleVersion = if (version == webUIPreviewVersion) {
|
||||
fetchPreviewVersion()
|
||||
} else {
|
||||
version
|
||||
}
|
||||
|
||||
val latestCompatibleVersion = getLatestCompatibleVersion()
|
||||
latestCompatibleVersion != currentVersion
|
||||
} catch (e: Exception) {
|
||||
logger.debug { "isUpdateAvailable: check failed due to $e" }
|
||||
|
||||
Reference in New Issue
Block a user