mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-03 19:04:39 -05:00
protobuf backup endpoints
This commit is contained in:
@@ -92,6 +92,12 @@ object MangaAPI {
|
|||||||
|
|
||||||
get("legacy/export", BackupController::legacyExport)
|
get("legacy/export", BackupController::legacyExport)
|
||||||
get("legacy/export/file", BackupController::legacyExportFile)
|
get("legacy/export/file", BackupController::legacyExportFile)
|
||||||
|
|
||||||
|
post("protobuf/import", BackupController::protobufImport)
|
||||||
|
post("protobuf/import/file", BackupController::protobufImportFile)
|
||||||
|
|
||||||
|
get("protobuf/export", BackupController::protobufExport)
|
||||||
|
get("protobuf/export/file", BackupController::protobufExportFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
path("downloads") {
|
path("downloads") {
|
||||||
|
|||||||
@@ -73,4 +73,62 @@ object BackupController {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** expects a Tachiyomi protobuf backup in the body */
|
||||||
|
fun protobufImport(ctx: Context) { // TODO
|
||||||
|
ctx.result(
|
||||||
|
JavalinSetup.future {
|
||||||
|
LegacyBackupImport.restoreLegacyBackup(ctx.bodyAsInputStream())
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** expects a Tachiyomi protobuf backup as a file upload, the file must be named "backup.proto" */
|
||||||
|
fun protobufImportFile(ctx: Context) { // TODO
|
||||||
|
ctx.result(
|
||||||
|
JavalinSetup.future {
|
||||||
|
LegacyBackupImport.restoreLegacyBackup(ctx.uploadedFile("backup.json")!!.content)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** returns a Tachiyomi protobuf backup created from the current database as a body */
|
||||||
|
fun protobufExport(ctx: Context) { // TODO
|
||||||
|
ctx.contentType("application/json")
|
||||||
|
ctx.result(
|
||||||
|
JavalinSetup.future {
|
||||||
|
LegacyBackupExport.createLegacyBackup(
|
||||||
|
BackupFlags(
|
||||||
|
includeManga = true,
|
||||||
|
includeCategories = true,
|
||||||
|
includeChapters = true,
|
||||||
|
includeTracking = true,
|
||||||
|
includeHistory = true,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** returns a Tachiyomi legacy backup json created from the current database as a file */
|
||||||
|
fun protobufExportFile(ctx: Context) {
|
||||||
|
ctx.contentType("application/json")
|
||||||
|
val sdf = SimpleDateFormat("yyyy-MM-dd_HH-mm")
|
||||||
|
val currentDate = sdf.format(Date())
|
||||||
|
|
||||||
|
ctx.header("Content-Disposition", "attachment; filename=\"tachidesk_$currentDate.json\"")
|
||||||
|
ctx.result(
|
||||||
|
JavalinSetup.future {
|
||||||
|
LegacyBackupExport.createLegacyBackup(
|
||||||
|
BackupFlags(
|
||||||
|
includeManga = true,
|
||||||
|
includeCategories = true,
|
||||||
|
includeChapters = true,
|
||||||
|
includeTracking = true,
|
||||||
|
includeHistory = true,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user