Skip to content

Commit

Permalink
Update served webUI after update
Browse files Browse the repository at this point in the history
The served file gets cached and thus, it won't reflect the latest version of the file.
This was a problem after the webUI got updated, since now the served "index.html" was outdated and pointed to files that didn't exist anymore.
  • Loading branch information
schroda committed Nov 7, 2023
1 parent b303291 commit f2b4bb9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,19 @@ object JavalinSetup {
val app =
Javalin.create { config ->
if (serverConfig.webUIEnabled.value) {
val serveWebUI = {
config.addSinglePageRoot("/", applicationDirs.webUIRoot + "/index.html", Location.EXTERNAL)
}
WebInterfaceManager.setServeWebUI(serveWebUI)

runBlocking {
WebInterfaceManager.setupWebUI()
}

logger.info { "Serving web static files for ${serverConfig.webUIFlavor.value}" }
config.addStaticFiles(applicationDirs.webUIRoot, Location.EXTERNAL)
config.addSinglePageRoot("/", applicationDirs.webUIRoot + "/index.html", Location.EXTERNAL)
serveWebUI()

config.registerPlugin(OpenApiPlugin(getOpenApiOptions()))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ object WebInterfaceManager {
)
}

private var serveWebUI: () -> Unit = {}

fun setServeWebUI(serveWebUI: () -> Unit) {
this.serveWebUI = serveWebUI
}

private fun isAutoUpdateEnabled(): Boolean {
return serverConfig.webUIUpdateCheckInterval.value.toInt() != 0
}
Expand Down Expand Up @@ -566,6 +572,8 @@ object WebInterfaceManager {
log.info { "Extracting WebUI zip Done." }

emitStatus(version, FINISHED, 100)

serveWebUI()
} catch (e: Exception) {
emitStatus(version, ERROR, 0)
throw e
Expand Down

0 comments on commit f2b4bb9

Please sign in to comment.