diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt index 8871c5a45..bd27935d1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt @@ -53,6 +53,7 @@ import tachiyomi.domain.library.service.LibraryPreferences.Companion.MANGA_HAS_U import tachiyomi.domain.library.service.LibraryPreferences.Companion.MANGA_NON_COMPLETED import tachiyomi.domain.library.service.LibraryPreferences.Companion.MANGA_NON_READ import tachiyomi.domain.library.service.LibraryPreferences.Companion.MANGA_OUTSIDE_RELEASE_PERIOD +import tachiyomi.domain.libraryUpdateError.interactor.DeleteLibraryUpdateErrors import tachiyomi.domain.libraryUpdateError.interactor.InsertLibraryUpdateErrors import tachiyomi.domain.libraryUpdateError.model.LibraryUpdateError import tachiyomi.domain.libraryUpdateErrorMessage.interactor.InsertLibraryUpdateErrorMessages @@ -87,6 +88,7 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet private val fetchInterval: FetchInterval = Injekt.get() private val filterChaptersForDownload: FilterChaptersForDownload = Injekt.get() + private val deleteLibraryUpdateErrors: DeleteLibraryUpdateErrors = Injekt.get() private val insertLibraryUpdateErrors: InsertLibraryUpdateErrors = Injekt.get() private val insertLibraryUpdateErrorMessages: InsertLibraryUpdateErrorMessages = Injekt.get() @@ -283,6 +285,7 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet // Convert to the manga that contains new chapters newUpdates.add(manga to newChapters.toTypedArray()) } + clearErrorFromDB(mangaId = manga.id) } catch (e: Throwable) { val errorMessage = when (e) { is NoChaptersException -> context.stringResource( @@ -379,6 +382,10 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet ) } + private suspend fun clearErrorFromDB(mangaId: Long) { + deleteLibraryUpdateErrors.deleteMangaError(mangaId = mangaId) + } + private suspend fun writeErrorToDB(error: Pair) { val errorMessage = error.second ?: "???" val errorMessageId = insertLibraryUpdateErrorMessages.get(errorMessage) diff --git a/data/src/main/java/tachiyomi/data/libraryUpdateError/LibraryUpdateErrorRepositoryImpl.kt b/data/src/main/java/tachiyomi/data/libraryUpdateError/LibraryUpdateErrorRepositoryImpl.kt index 819322c8e..061d18103 100644 --- a/data/src/main/java/tachiyomi/data/libraryUpdateError/LibraryUpdateErrorRepositoryImpl.kt +++ b/data/src/main/java/tachiyomi/data/libraryUpdateError/LibraryUpdateErrorRepositoryImpl.kt @@ -37,6 +37,14 @@ class LibraryUpdateErrorRepositoryImpl( } } + override suspend fun deleteMangaError(mangaId: Long) { + return handler.await { + libraryUpdateErrorQueries.deleteMangaError( + mangaId = mangaId, + ) + } + } + override suspend fun upsert(libraryUpdateError: LibraryUpdateError) { return handler.await(inTransaction = true) { libraryUpdateErrorQueries.upsert( diff --git a/data/src/main/sqldelight/tachiyomi/data/libraryUpdateError.sq b/data/src/main/sqldelight/tachiyomi/data/libraryUpdateError.sq index 51f6afe85..e268b38c4 100644 --- a/data/src/main/sqldelight/tachiyomi/data/libraryUpdateError.sq +++ b/data/src/main/sqldelight/tachiyomi/data/libraryUpdateError.sq @@ -25,4 +25,8 @@ DELETE FROM libraryUpdateError; deleteError: DELETE FROM libraryUpdateError -WHERE _id = :_id; \ No newline at end of file +WHERE _id = :_id; + +deleteMangaError: +DELETE FROM libraryUpdateError +WHERE manga_id = :mangaId; \ No newline at end of file diff --git a/domain/src/main/java/tachiyomi/domain/libraryUpdateError/interactor/DeleteLibraryUpdateErrors.kt b/domain/src/main/java/tachiyomi/domain/libraryUpdateError/interactor/DeleteLibraryUpdateErrors.kt index 89dee977e..db637c2ce 100644 --- a/domain/src/main/java/tachiyomi/domain/libraryUpdateError/interactor/DeleteLibraryUpdateErrors.kt +++ b/domain/src/main/java/tachiyomi/domain/libraryUpdateError/interactor/DeleteLibraryUpdateErrors.kt @@ -29,6 +29,16 @@ class DeleteLibraryUpdateErrors( } } + suspend fun deleteMangaError(mangaId: Long) = withNonCancellableContext { + try { + libraryUpdateErrorRepository.deleteMangaError(mangaId) + Result.Success + } catch (e: Exception) { + logcat(LogPriority.ERROR, e) + return@withNonCancellableContext Result.InternalError(e) + } + } + sealed class Result { object Success : Result() data class InternalError(val error: Throwable) : Result() diff --git a/domain/src/main/java/tachiyomi/domain/libraryUpdateError/repository/LibraryUpdateErrorRepository.kt b/domain/src/main/java/tachiyomi/domain/libraryUpdateError/repository/LibraryUpdateErrorRepository.kt index c76a3511b..044e97203 100644 --- a/domain/src/main/java/tachiyomi/domain/libraryUpdateError/repository/LibraryUpdateErrorRepository.kt +++ b/domain/src/main/java/tachiyomi/domain/libraryUpdateError/repository/LibraryUpdateErrorRepository.kt @@ -13,6 +13,8 @@ interface LibraryUpdateErrorRepository { suspend fun delete(errorId: Long) + suspend fun deleteMangaError(mangaId: Long) + suspend fun upsert(libraryUpdateError: LibraryUpdateError) suspend fun insert(libraryUpdateError: LibraryUpdateError)