mirror of
https://github.com/mihonapp/mihon.git
synced 2026-10-16 13:48:09 -07:00
Apply chapter sync in one transaction
A chapter sync's removals, inserts and updates go through one ChapterRepository.updateFromRemote call, applied atomically. A failure no longer leaves some of a sync's changes written and others missing. Restore folds duplicate chapters in a backup into one before writing, and the chapter deep link looks up the synced chapter afterwards rather than relying on the sync's return value.
This commit is contained in:
@@ -3,7 +3,6 @@ package tachiyomi.domain.chapter.interactor
|
||||
import dev.zacsweers.metro.Inject
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.common.util.system.logcat
|
||||
import tachiyomi.domain.chapter.model.ChapterRemoteUpdate
|
||||
import tachiyomi.domain.chapter.model.ChapterUpdate
|
||||
import tachiyomi.domain.chapter.repository.ChapterRepository
|
||||
|
||||
@@ -27,12 +26,4 @@ class UpdateChapter(
|
||||
logcat(LogPriority.ERROR, e)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun awaitAllRemote(chapterUpdates: List<ChapterRemoteUpdate>) {
|
||||
try {
|
||||
chapterRepository.updateAllRemote(chapterUpdates)
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,15 +7,15 @@ import tachiyomi.domain.chapter.model.ChapterUpdate
|
||||
|
||||
interface ChapterRepository {
|
||||
|
||||
suspend fun addAll(chapters: List<Chapter>): List<Chapter>
|
||||
|
||||
suspend fun update(chapterUpdate: ChapterUpdate)
|
||||
|
||||
suspend fun updateAll(chapterUpdates: List<ChapterUpdate>)
|
||||
|
||||
suspend fun updateAllRemote(chapterUpdates: List<ChapterRemoteUpdate>)
|
||||
|
||||
suspend fun removeChaptersWithIds(chapterIds: List<Long>)
|
||||
suspend fun updateFromRemote(
|
||||
removedIds: List<Long>,
|
||||
added: List<Chapter>,
|
||||
updated: List<ChapterRemoteUpdate>,
|
||||
): List<Chapter>
|
||||
|
||||
suspend fun getChapterByMangaId(mangaId: Long, applyScanlatorFilter: Boolean = false): List<Chapter>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user