Skip to content

Commit c38a3d9

Browse files
authored
Update served webUI after update (#764)
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.
1 parent b303291 commit c38a3d9

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

server/src/main/kotlin/suwayomi/tachidesk/server/JavalinSetup.kt

+7-1
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,19 @@ object JavalinSetup {
7272
val app =
7373
Javalin.create { config ->
7474
if (serverConfig.webUIEnabled.value) {
75+
val serveWebUI = {
76+
config.addSinglePageRoot("/", applicationDirs.webUIRoot + "/index.html", Location.EXTERNAL)
77+
}
78+
WebInterfaceManager.setServeWebUI(serveWebUI)
79+
7580
runBlocking {
7681
WebInterfaceManager.setupWebUI()
7782
}
7883

7984
logger.info { "Serving web static files for ${serverConfig.webUIFlavor.value}" }
8085
config.addStaticFiles(applicationDirs.webUIRoot, Location.EXTERNAL)
81-
config.addSinglePageRoot("/", applicationDirs.webUIRoot + "/index.html", Location.EXTERNAL)
86+
serveWebUI()
87+
8288
config.registerPlugin(OpenApiPlugin(getOpenApiOptions()))
8389
}
8490

server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt

+8
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ object WebInterfaceManager {
167167
)
168168
}
169169

170+
private var serveWebUI: () -> Unit = {}
171+
172+
fun setServeWebUI(serveWebUI: () -> Unit) {
173+
this.serveWebUI = serveWebUI
174+
}
175+
170176
private fun isAutoUpdateEnabled(): Boolean {
171177
return serverConfig.webUIUpdateCheckInterval.value.toInt() != 0
172178
}
@@ -566,6 +572,8 @@ object WebInterfaceManager {
566572
log.info { "Extracting WebUI zip Done." }
567573

568574
emitStatus(version, FINISHED, 100)
575+
576+
serveWebUI()
569577
} catch (e: Exception) {
570578
emitStatus(version, ERROR, 0)
571579
throw e

0 commit comments

Comments
 (0)