mirror of
https://github.com/mihonapp/mihon.git
synced 2026-10-20 07:32:28 -07:00
Split the universal update queries into case-specific ones
Source-owned fields move out of MangaUpdate/ChapterUpdate into MangaRemoteUpdate/ChapterRemoteUpdate, which only UpdateMangaFromRemote and SyncChaptersWithSource write. Backup restore gets its own updateFromBackup queries for entries and chapters, writing only what a backup carries.
This commit is contained in:
@@ -15,6 +15,7 @@ import tachiyomi.core.common.util.system.logcat
|
||||
import tachiyomi.data.Database
|
||||
import tachiyomi.data.subscribeToList
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
import tachiyomi.domain.chapter.model.ChapterRemoteUpdate
|
||||
import tachiyomi.domain.chapter.model.ChapterUpdate
|
||||
import tachiyomi.domain.chapter.repository.ChapterRepository
|
||||
|
||||
@@ -61,23 +62,32 @@ class ChapterRepositoryImpl(
|
||||
partialUpdate(*chapterUpdates.toTypedArray())
|
||||
}
|
||||
|
||||
override suspend fun updateAllRemote(chapterUpdates: List<ChapterRemoteUpdate>) {
|
||||
database.transaction {
|
||||
chapterUpdates.forEach { chapterUpdate ->
|
||||
database.chaptersQueries.updateRemote(
|
||||
name = chapterUpdate.name,
|
||||
scanlator = chapterUpdate.scanlator,
|
||||
chapterNumber = chapterUpdate.chapterNumber,
|
||||
sourceOrder = chapterUpdate.sourceOrder,
|
||||
dateUpload = chapterUpdate.dateUpload,
|
||||
chapterId = chapterUpdate.id,
|
||||
memo = chapterUpdate.memo,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun partialUpdate(vararg chapterUpdates: ChapterUpdate) {
|
||||
database.transaction {
|
||||
chapterUpdates.forEach { chapterUpdate ->
|
||||
database.chaptersQueries.update(
|
||||
mangaId = chapterUpdate.mangaId,
|
||||
url = chapterUpdate.url,
|
||||
name = chapterUpdate.name,
|
||||
scanlator = chapterUpdate.scanlator,
|
||||
read = chapterUpdate.read,
|
||||
bookmark = chapterUpdate.bookmark,
|
||||
lastPageRead = chapterUpdate.lastPageRead,
|
||||
chapterNumber = chapterUpdate.chapterNumber,
|
||||
sourceOrder = chapterUpdate.sourceOrder,
|
||||
dateFetch = chapterUpdate.dateFetch,
|
||||
dateUpload = chapterUpdate.dateUpload,
|
||||
chapterId = chapterUpdate.id,
|
||||
memo = chapterUpdate.memo,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import tachiyomi.data.subscribeToOne
|
||||
import tachiyomi.data.subscribeToOneOrNull
|
||||
import tachiyomi.domain.library.model.LibraryManga
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.manga.model.MangaRemoteUpdate
|
||||
import tachiyomi.domain.manga.model.MangaUpdate
|
||||
import tachiyomi.domain.manga.model.MangaWithChapterCount
|
||||
import tachiyomi.domain.manga.repository.MangaRepository
|
||||
@@ -185,32 +186,43 @@ class MangaRepositoryImpl(
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun updateRemote(update: MangaRemoteUpdate): Boolean {
|
||||
return try {
|
||||
database.mangasQueries.updateRemote(
|
||||
artist = update.artist,
|
||||
author = update.author,
|
||||
description = update.description,
|
||||
genre = update.genre,
|
||||
title = update.title,
|
||||
status = update.status,
|
||||
thumbnailUrl = update.thumbnailUrl,
|
||||
initialized = update.initialized,
|
||||
coverLastModified = update.coverLastModified,
|
||||
updateStrategy = update.updateStrategy,
|
||||
memo = update.memo,
|
||||
mangaId = update.id,
|
||||
)
|
||||
true
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun partialUpdate(vararg mangaUpdates: MangaUpdate) {
|
||||
database.transaction {
|
||||
mangaUpdates.forEach { value ->
|
||||
database.mangasQueries.update(
|
||||
source = value.source,
|
||||
url = value.url,
|
||||
artist = value.artist,
|
||||
author = value.author,
|
||||
description = value.description,
|
||||
genre = value.genre,
|
||||
title = value.title,
|
||||
status = value.status,
|
||||
thumbnailUrl = value.thumbnailUrl,
|
||||
favorite = value.favorite,
|
||||
lastUpdate = value.lastUpdate,
|
||||
nextUpdate = value.nextUpdate,
|
||||
calculateInterval = value.fetchInterval?.toLong(),
|
||||
initialized = value.initialized,
|
||||
viewer = value.viewerFlags,
|
||||
chapterFlags = value.chapterFlags,
|
||||
coverLastModified = value.coverLastModified,
|
||||
dateAdded = value.dateAdded,
|
||||
mangaId = value.id,
|
||||
updateStrategy = value.updateStrategy,
|
||||
notes = value.notes,
|
||||
memo = value.memo,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user