Keep a stored track's remote entry when restoring

Restoring over an existing track took the backup's remote id and library id but kept the stored url and title, pairing one remote entry's id with another's details. The stored track now wins like the rest of an entry's stored data, and the backup only moves its last chapter read forward.
This commit is contained in:
AntsyLich
2026-09-27 23:09:32 +06:00
parent 9a77baedcc
commit 4b48a84ec9
@@ -257,17 +257,10 @@ class RestoreRepositoryImpl(
mangaId = manga.id,
)
if (track.forComparison() == dbTrack.forComparison()) {
// Same state; skip
return@mapNotNull null
}
if (track.lastChapterRead <= dbTrack.lastChapterRead) return@mapNotNull null
// Update to an existing track
dbTrack.copy(
remoteId = track.remoteId,
libraryId = track.libraryId,
lastChapterRead = max(dbTrack.lastChapterRead, track.lastChapterRead),
)
dbTrack.copy(lastChapterRead = track.lastChapterRead)
}
.partition { it.id > 0 }
@@ -295,8 +288,6 @@ class RestoreRepositoryImpl(
}
}
private fun Track.forComparison() = this.copy(id = 0L, mangaId = 0L)
private suspend fun restoreExcludedScanlators(manga: Manga, excludedScanlators: List<String>) {
if (excludedScanlators.isEmpty()) return
val existingExcludedScanlators = database.excluded_scanlatorsQueries