Update an existing track in place instead of replacing it
Upserting a track for an entry and tracker that already have one updates that row, instead of the table's REPLACE deleting it and inserting a new one under a new id. Anything keyed to the old id, such as a queued tracking update, keeps working. The query, repository methods and interactor are renamed from insert to upsert to say so.
This commit is contained in:
+3
-3
@@ -7,13 +7,13 @@ import tachiyomi.domain.track.model.Track
|
||||
import tachiyomi.domain.track.repository.TrackRepository
|
||||
|
||||
@Inject
|
||||
class InsertTrack(
|
||||
class UpsertTrack(
|
||||
private val trackRepository: TrackRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(track: Track) {
|
||||
try {
|
||||
trackRepository.insert(track)
|
||||
trackRepository.upsert(track)
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
}
|
||||
@@ -21,7 +21,7 @@ class InsertTrack(
|
||||
|
||||
suspend fun awaitAll(tracks: List<Track>) {
|
||||
try {
|
||||
trackRepository.insertAll(tracks)
|
||||
trackRepository.upsertAll(tracks)
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
}
|
||||
@@ -15,7 +15,7 @@ interface TrackRepository {
|
||||
|
||||
suspend fun delete(mangaId: Long, trackerId: Long)
|
||||
|
||||
suspend fun insert(track: Track)
|
||||
suspend fun upsert(track: Track)
|
||||
|
||||
suspend fun insertAll(tracks: List<Track>)
|
||||
suspend fun upsertAll(tracks: List<Track>)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user