Fix/webinterfacemanager update to bundled webui (#648)

* Catch error when updating to bundled webUI

In case the bundled webUI is missing, the webUI setup threw an error and made the server startup fail.
Since a local webUI exists the error should be ignored, since it's only a try to update to a newer webUI version.

* Extract logic to setup bundled webUI version

* Update to bundled webUI try to download missing bundled webUI
This commit is contained in:
schroda
2023-08-10 02:46:33 +02:00
committed by GitHub
parent f6fec2424c
commit 684bb1875c

View File

@@ -128,8 +128,13 @@ object WebInterfaceManager {
BuildConfig.WEBUI_TAG
)
if (shouldUpdateToBundledVersion) {
logger.debug { "Update to bundled version \"${BuildConfig.WEBUI_TAG}\"" }
extractBundledWebUI()
logger.debug { "setupWebUI: update to bundled version \"${BuildConfig.WEBUI_TAG}\"" }
try {
setupBundledWebUI()
} catch (e: Exception) {
logger.error(e) { "setupWebUI: failed the update to the bundled webUI" }
}
}
return
@@ -178,17 +183,22 @@ object WebInterfaceManager {
logger.warn { "doInitialSetup: fallback to bundled default webUI \"$DEFAULT_WEB_UI\"" }
try {
setupBundledWebUI()
} catch (e: Exception) {
throw Exception("Unable to setup a webUI")
}
}
private fun setupBundledWebUI() {
try {
extractBundledWebUI()
return
} catch (e: BundledWebUIMissing) {
logger.warn(e) { "doInitialSetup: fallback to downloading the version of the bundled webUI" }
logger.warn(e) { "setupBundledWebUI: fallback to downloading the version of the bundled webUI" }
}
val downloadFailed = !doDownload() { BuildConfig.WEBUI_TAG }
if (downloadFailed) {
throw Exception("Unable to setup a webUI")
}
downloadVersion(BuildConfig.WEBUI_TAG)
}
private fun extractBundledWebUI() {