diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/create/creators/MangaBackupCreator.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/create/creators/MangaBackupCreator.kt index 1c03f7fce..9f51a0d55 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/create/creators/MangaBackupCreator.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/create/creators/MangaBackupCreator.kt @@ -30,6 +30,10 @@ class MangaBackupCreator( // Entry for this manga val mangaObject = manga.toBackupManga() + mangaObject.excludedScanlators = handler.awaitList { + excluded_scanlatorsQueries.getExcludedScanlatorsByMangaId(manga.id) + } + if (options.chapters) { // Backup all the chapters handler.awaitList { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupManga.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupManga.kt index 43a8a906c..da202ae55 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupManga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupManga.kt @@ -38,6 +38,7 @@ data class BackupManga( @ProtoNumber(105) var updateStrategy: UpdateStrategy = UpdateStrategy.ALWAYS_UPDATE, @ProtoNumber(106) var lastModifiedAt: Long = 0, @ProtoNumber(107) var favoriteModifiedAt: Long? = null, + @ProtoNumber(108) var excludedScanlators: List = emptyList(), ) { fun getMangaImpl(): Manga { return Manga.create().copy( diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/restorers/MangaRestorer.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/restorers/MangaRestorer.kt index f6b9455a3..30dc44368 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/restorers/MangaRestorer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/restorers/MangaRestorer.kt @@ -73,6 +73,7 @@ class MangaRestorer( backupCategories = backupCategories, history = backupManga.history + backupManga.brokenHistory.map { it.toBackupHistory() }, tracks = backupManga.tracking, + excludedScanlators = backupManga.excludedScanlators, ) } } @@ -264,11 +265,13 @@ class MangaRestorer( backupCategories: List, history: List, tracks: List, + excludedScanlators: List, ): Manga { restoreCategories(manga, categories, backupCategories) restoreChapters(manga, chapters) restoreTracking(manga, tracks) restoreHistory(history) + restoreExcludedScanlators(manga, excludedScanlators) updateManga.awaitUpdateFetchInterval(manga, now, currentFetchWindow) return manga } @@ -401,4 +404,25 @@ class MangaRestorer( } private fun Track.forComparison() = this.copy(id = 0L, mangaId = 0L) + + /** + * Restores the excluded scanlators for the manga. + * + * @param manga the manga whose excluded scanlators have to be restored. + * @param excludedScanlators the excluded scanlators to restore. + */ + private suspend fun restoreExcludedScanlators(manga: Manga, excludedScanlators: List) { + if (excludedScanlators.isEmpty()) return + val existingExcludedScanlators = handler.awaitList { + excluded_scanlatorsQueries.getExcludedScanlatorsByMangaId(manga.id) + } + val toInsert = excludedScanlators.filter { it !in existingExcludedScanlators } + if (toInsert.isNotEmpty()) { + handler.await { + toInsert.forEach { + excluded_scanlatorsQueries.insert(manga.id, it) + } + } + } + } }