From 684bb1875c667a8887bfeebcf8c38e1d9c23b8fd Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Thu, 10 Aug 2023 02:46:33 +0200 Subject: [PATCH] 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 --- .../server/util/WebInterfaceManager.kt | 24 +++++++++++++------ 1 file changed, 17 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 fcc42e3b..2c6f9856 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt @@ -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() {