Fix (MangaRestorer): avoid exception caused by duplicate entries
Duplicate chapters or duplicate merge-reference which would leads to the whole manga failed to restore/add to library
This commit is contained in:
parent
58dc3b3e79
commit
caa0d9b92e
1 changed files with 11 additions and 3 deletions
|
|
@ -393,7 +393,10 @@ class MangaRestorer(
|
|||
|
||||
private suspend fun restoreHistory(manga: Manga, backupHistory: List<BackupHistory>) {
|
||||
val toUpdate = backupHistory.mapNotNull { history ->
|
||||
val dbHistory = handler.awaitOneOrNull { historyQueries.getHistoryByChapterUrl(manga.id, history.url) }
|
||||
// KMK -->
|
||||
val dbHistory = handler.awaitList { historyQueries.getHistoryByChapterUrl(manga.id, history.url) }
|
||||
.firstOrNull()
|
||||
// KMK <--
|
||||
val item = history.getHistoryImpl()
|
||||
|
||||
if (dbHistory == null) {
|
||||
|
|
@ -514,13 +517,18 @@ class MangaRestorer(
|
|||
}
|
||||
) {
|
||||
// Let the db assign the id
|
||||
val mergedManga = handler.awaitOneOrNull {
|
||||
// KMK -->
|
||||
val mergedManga = handler.awaitList {
|
||||
// KMK <--
|
||||
mangasQueries.getMangaByUrlAndSource(
|
||||
backupMergedMangaReference.mangaUrl,
|
||||
backupMergedMangaReference.mangaSourceId,
|
||||
MangaMapper::mapManga,
|
||||
)
|
||||
} ?: return@forEach
|
||||
// KMK -->
|
||||
}.firstOrNull()
|
||||
// KMK <--
|
||||
?: return@forEach
|
||||
backupMergedMangaReference.getMergedMangaReference().run {
|
||||
handler.await {
|
||||
mergedQueries.insert(
|
||||
|
|
|
|||
Loading…
Reference in a new issue