Fix: duplicate chapters on backup restoring (#565)
This commit is contained in:
parent
23d53a4560
commit
8c4b43c5aa
1 changed files with 18 additions and 3 deletions
|
|
@ -189,7 +189,7 @@ class MangaRestorer(
|
|||
when {
|
||||
dbChapter == null -> chapter // New chapter
|
||||
chapter.forComparison() == dbChapter.forComparison() -> null // Same state; skip
|
||||
else -> updateChapterBasedOnSyncState(chapter, dbChapter)
|
||||
else -> updateChapterBasedOnSyncState(chapter, dbChapter) // Update existed chapter
|
||||
}
|
||||
}
|
||||
.partition { it.id > 0 }
|
||||
|
|
@ -217,11 +217,24 @@ class MangaRestorer(
|
|||
else -> it
|
||||
}
|
||||
}
|
||||
// KMK -->
|
||||
.copy(id = dbChapter.id)
|
||||
// KMK <--
|
||||
}
|
||||
}
|
||||
|
||||
private fun Chapter.forComparison() =
|
||||
this.copy(id = 0L, mangaId = 0L, dateFetch = 0L, dateUpload = 0L, lastModifiedAt = 0L, version = 0L)
|
||||
this.copy(
|
||||
id = 0L,
|
||||
mangaId = 0L,
|
||||
dateFetch = 0L,
|
||||
// KMK -->
|
||||
// dateUpload = 0L, some time source loses dateUpload so we overwrite with backup
|
||||
sourceOrder = 0L, // ignore sourceOrder since it will be updated on refresh
|
||||
// KMK <--
|
||||
lastModifiedAt = 0L,
|
||||
version = 0L,
|
||||
)
|
||||
|
||||
private suspend fun insertNewChapters(chapters: List<Chapter>) {
|
||||
handler.await(true) {
|
||||
|
|
@ -258,7 +271,9 @@ class MangaRestorer(
|
|||
chapterNumber = null,
|
||||
sourceOrder = if (isSync) chapter.sourceOrder else null,
|
||||
dateFetch = null,
|
||||
dateUpload = null,
|
||||
// KMK -->
|
||||
dateUpload = chapter.dateUpload,
|
||||
// KMK <--
|
||||
chapterId = chapter.id,
|
||||
version = chapter.version,
|
||||
isSyncing = 1,
|
||||
|
|
|
|||
Loading…
Reference in a new issue