add backup validation endpoints

This commit is contained in:
Aria Moradi
2021-08-21 06:08:17 +04:30
parent c29a749833
commit e93d66d8a1
4 changed files with 38 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ import suwayomi.tachidesk.manga.impl.backup.legacy.LegacyBackupExport
import suwayomi.tachidesk.manga.impl.backup.legacy.LegacyBackupImport
import suwayomi.tachidesk.manga.impl.backup.proto.ProtoBackupExport
import suwayomi.tachidesk.manga.impl.backup.proto.ProtoBackupImport
import suwayomi.tachidesk.manga.impl.backup.proto.ProtoBackupValidator
import suwayomi.tachidesk.server.JavalinSetup
import java.text.SimpleDateFormat
import java.util.Date
@@ -77,7 +78,7 @@ object BackupController {
/** expects a Tachiyomi protobuf backup in the body */
fun protobufImport(ctx: Context) {
ctx.result(
ctx.json(
JavalinSetup.future {
ProtoBackupImport.performRestore(ctx.bodyAsInputStream())
}
@@ -86,7 +87,7 @@ object BackupController {
/** expects a Tachiyomi protobuf backup as a file upload, the file must be named "backup.proto.gz" */
fun protobufImportFile(ctx: Context) {
ctx.result(
ctx.json(
JavalinSetup.future {
ProtoBackupImport.performRestore(ctx.uploadedFile("backup.proto.gz")!!.content)
}
@@ -94,7 +95,7 @@ object BackupController {
}
/** returns a Tachiyomi protobuf backup created from the current database as a body */
fun protobufExport(ctx: Context) { // TODO
fun protobufExport(ctx: Context) {
ctx.contentType("application/octet-stream")
ctx.result(
JavalinSetup.future {
@@ -131,4 +132,22 @@ object BackupController {
}
)
}
/** Reports missing sources and trackers, expects a Tachiyomi protobuf backup in the body */
fun protobufValidate(ctx: Context) { // TODO
ctx.json(
JavalinSetup.future {
ProtoBackupValidator.validate(ctx.bodyAsInputStream())
}
)
}
/** Reports missing sources and trackers, expects a Tachiyomi protobuf backup as a file upload, the file must be named "backup.proto.gz" */
fun protobufValidateFile(ctx: Context) {
ctx.json(
JavalinSetup.future {
ProtoBackupValidator.validate(ctx.uploadedFile("backup.proto.gz")!!.content)
}
)
}
}