Add Route to stop and reset the updater (#260)

This commit is contained in:
Sascha Hahne
2021-12-01 20:48:32 +01:00
committed by GitHub
parent 205101568e
commit 76c7bdd604
2 changed files with 24 additions and 0 deletions
@@ -114,6 +114,7 @@ object MangaAPI {
path("update") {
get("recentChapters/{pageNum}", UpdateController::recentChapters)
post("fetch", UpdateController::categoryUpdate)
post("reset", UpdateController.reset)
get("summary", UpdateController::updateSummary)
ws("", UpdateController::categoryUpdateWS)
}
@@ -15,6 +15,8 @@ import suwayomi.tachidesk.manga.impl.update.IUpdater
import suwayomi.tachidesk.manga.impl.update.UpdaterSocket
import suwayomi.tachidesk.manga.model.dataclass.CategoryDataClass
import suwayomi.tachidesk.server.JavalinSetup.future
import suwayomi.tachidesk.server.util.handler
import suwayomi.tachidesk.server.util.withOperation
/*
* Copyright (C) Contributors to the Suwayomi project
@@ -86,4 +88,25 @@ object UpdateController {
val updater by DI.global.instance<IUpdater>()
ctx.json(updater.getStatus().value.getJsonSummary())
}
val reset = handler(
documentWith = {
withOperation {
summary("Stops and resets the Updater")
}
},
behaviorOf = { ctx ->
val updater by DI.global.instance<IUpdater>()
logger.info { "Resetting Updater" }
ctx.future(
future {
updater.reset()
}.thenApply {
ctx.status(HttpCode.OK)
}
)
},
withResults = {
}
)
}