Backup creation and restore gql endpoints (#587)

This commit is contained in:
Mitchell Syer
2023-07-02 11:45:44 -04:00
committed by GitHub
parent 1a9a0b3394
commit a11b654c3d
13 changed files with 477 additions and 43 deletions

View File

@@ -11,7 +11,9 @@ import io.javalin.http.ContentType
import io.javalin.http.Context
import io.javalin.websocket.WsConfig
import suwayomi.tachidesk.graphql.server.TachideskGraphQLServer
import suwayomi.tachidesk.graphql.server.TemporaryFileStorage
import suwayomi.tachidesk.server.JavalinSetup.future
import kotlin.io.path.inputStream
object GraphQLController {
private val server = TachideskGraphQLServer.create()
@@ -30,6 +32,14 @@ object GraphQLController {
ctx.result(javaClass.getResourceAsStream("/graphql-playground.html")!!)
}
fun retrieveFile(ctx: Context) {
val filename = ctx.pathParam("file")
val file = TemporaryFileStorage.retrieveFile(filename)
ctx.contentType("application/octet-stream")
ctx.header("Content-Disposition", """attachment; filename="$filename"""")
ctx.result(file.inputStream())
}
fun webSocket(ws: WsConfig) {
ws.onMessage { ctx ->
server.handleSubscriptionMessage(ctx)