Backup and Restore Excluded scanlators (#166)
* Backup and Restore Excluded scanlators * Improve performance * This looks better (cherry picked from commit e0deeb800890c5e3be67c4ebe32ebe34d97e0e25)
This commit is contained in:
parent
7b92d06eee
commit
27d8896937
@ -66,6 +66,10 @@ class MangaBackupCreator(
|
||||
}
|
||||
// SY <--
|
||||
|
||||
mangaObject.excludedScanlators = handler.awaitList {
|
||||
excluded_scanlatorsQueries.getExcludedScanlatorsByMangaId(manga.id)
|
||||
}
|
||||
|
||||
if (options.chapters) {
|
||||
// Backup all the chapters
|
||||
handler.awaitList {
|
||||
|
@ -39,6 +39,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<String> = emptyList(),
|
||||
|
||||
// SY specific values
|
||||
@ProtoNumber(600) var mergedMangaReferences: List<BackupMergedMangaReference> = emptyList(),
|
||||
@ -52,9 +53,6 @@ data class BackupManga(
|
||||
// skipping 803 due to using duplicate value in previous builds
|
||||
@ProtoNumber(804) var customDescription: String? = null,
|
||||
@ProtoNumber(805) var customGenre: List<String>? = null,
|
||||
|
||||
// Neko specific values
|
||||
@ProtoNumber(901) var filtered_scanlators: String? = null,
|
||||
) {
|
||||
fun getMangaImpl(): Manga {
|
||||
return Manga.create().copy(
|
||||
|
@ -90,6 +90,7 @@ class MangaRestorer(
|
||||
backupCategories = backupCategories,
|
||||
history = backupManga.history + backupManga.brokenHistory.map { it.toBackupHistory() },
|
||||
tracks = backupManga.tracking,
|
||||
excludedScanlators = backupManga.excludedScanlators,
|
||||
// SY -->
|
||||
mergedMangaReferences = backupManga.mergedMangaReferences,
|
||||
flatMetadata = backupManga.flatMetadata,
|
||||
@ -288,6 +289,7 @@ class MangaRestorer(
|
||||
backupCategories: List<BackupCategory>,
|
||||
history: List<BackupHistory>,
|
||||
tracks: List<BackupTracking>,
|
||||
excludedScanlators: List<String>,
|
||||
// SY -->
|
||||
mergedMangaReferences: List<BackupMergedMangaReference>,
|
||||
flatMetadata: BackupFlatMetadata?,
|
||||
@ -298,6 +300,7 @@ class MangaRestorer(
|
||||
restoreChapters(manga, chapters)
|
||||
restoreTracking(manga, tracks)
|
||||
restoreHistory(history)
|
||||
restoreExcludedScanlators(manga, excludedScanlators)
|
||||
updateManga.awaitUpdateFetchInterval(manga, now, currentFetchWindow)
|
||||
// SY -->
|
||||
restoreMergedMangaReferencesForManga(manga.id, mergedMangaReferences)
|
||||
@ -523,4 +526,25 @@ class MangaRestorer(
|
||||
// SY <--
|
||||
|
||||
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<String>) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user