mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-06-30 09:24:34 -05:00
Fix Postgres Backups (#2113)
* Fix Postgres Backups * Changelog * Import * More accurate changelog
This commit is contained in:
@@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||
- (**API**) Fix GraphQL `Filter` `notAll` and `notAny` being inversed
|
||||
- (**API**) Fix GraphQL `Filter` causing an UnsupportedOperationException when passing an empty list as a `Any` filter value
|
||||
- (**Build**) Fix CURL failing silently in builds
|
||||
- (**Backup/Database**) Fix backup creation slowdown when mapping chapters
|
||||
|
||||
## [v2.2.2100] + [WebUI: v20260508.01] - 2026-05-08
|
||||
|
||||
|
||||
@@ -148,13 +148,11 @@ object ProtoBackupExport : ProtoBackupBase() {
|
||||
|
||||
fun createBackup(flags: BackupFlags): InputStream {
|
||||
// Create root object
|
||||
|
||||
val backupMangas = BackupMangaHandler.backup(flags)
|
||||
|
||||
val backup: Backup =
|
||||
transaction {
|
||||
val backupMangas = BackupMangaHandler.backup(flags)
|
||||
Backup(
|
||||
BackupMangaHandler.backup(flags),
|
||||
backupMangas,
|
||||
BackupCategoryHandler.backup(flags),
|
||||
BackupSourceHandler.backup(backupMangas, flags),
|
||||
BackupGlobalMetaHandler.backup(flags),
|
||||
|
||||
@@ -38,7 +38,6 @@ import suwayomi.tachidesk.manga.model.dataclass.TrackRecordDataClass
|
||||
import suwayomi.tachidesk.manga.model.table.ChapterTable
|
||||
import suwayomi.tachidesk.manga.model.table.MangaStatus
|
||||
import suwayomi.tachidesk.manga.model.table.MangaTable
|
||||
import suwayomi.tachidesk.manga.model.table.toDataClass
|
||||
import suwayomi.tachidesk.server.database.dbTransaction
|
||||
import java.util.Date
|
||||
import kotlin.math.max
|
||||
@@ -92,31 +91,31 @@ object BackupMangaHandler {
|
||||
.selectAll()
|
||||
.where { ChapterTable.manga eq mangaId }
|
||||
.orderBy(ChapterTable.sourceOrder to SortOrder.DESC)
|
||||
.map {
|
||||
ChapterTable.toDataClass(it)
|
||||
}
|
||||
.toList()
|
||||
}
|
||||
|
||||
if (flags.includeChapters) {
|
||||
val chapterToMeta = Chapter.getChaptersMetaMaps(chapters.map { it.id })
|
||||
val chapterToMeta =
|
||||
Chapter.getChaptersMetaMaps(chapters.map { it[ChapterTable.id].value })
|
||||
|
||||
backupManga.chapters =
|
||||
chapters.map {
|
||||
BackupChapter(
|
||||
it.url,
|
||||
it.name,
|
||||
it.scanlator,
|
||||
it.read,
|
||||
it.bookmarked,
|
||||
it.lastPageRead,
|
||||
it.fetchedAt.seconds.inWholeMilliseconds,
|
||||
it.uploadDate,
|
||||
it.chapterNumber,
|
||||
chapters.size - it.index,
|
||||
it.lastModifiedAt,
|
||||
it.version,
|
||||
url = it[ChapterTable.url],
|
||||
name = it[ChapterTable.name],
|
||||
scanlator = it[ChapterTable.scanlator],
|
||||
read = it[ChapterTable.isRead],
|
||||
bookmark = it[ChapterTable.isBookmarked],
|
||||
lastPageRead = it[ChapterTable.lastPageRead],
|
||||
dateFetch = it[ChapterTable.fetchedAt].seconds.inWholeMilliseconds,
|
||||
dateUpload = it[ChapterTable.date_upload],
|
||||
chapterNumber = it[ChapterTable.chapter_number],
|
||||
sourceOrder = chapters.size - it[ChapterTable.sourceOrder],
|
||||
lastModifiedAt = it[ChapterTable.lastModifiedAt],
|
||||
version = it[ChapterTable.version],
|
||||
).apply {
|
||||
if (flags.includeClientData) {
|
||||
this.meta = chapterToMeta[it.id] ?: emptyMap()
|
||||
this.meta = chapterToMeta[it[ChapterTable.id].value] ?: emptyMap()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,10 +123,10 @@ object BackupMangaHandler {
|
||||
if (flags.includeHistory) {
|
||||
backupManga.history =
|
||||
chapters.mapNotNull {
|
||||
if (it.lastReadAt > 0) {
|
||||
if (it[ChapterTable.lastReadAt] > 0) {
|
||||
BackupHistory(
|
||||
url = it.url,
|
||||
lastRead = it.lastReadAt.seconds.inWholeMilliseconds,
|
||||
url = it[ChapterTable.url],
|
||||
lastRead = it[ChapterTable.lastReadAt].seconds.inWholeMilliseconds,
|
||||
)
|
||||
} else {
|
||||
null
|
||||
|
||||
Reference in New Issue
Block a user