mirror of
https://github.com/mihonapp/mihon.git
synced 2025-01-30 20:04:56 +01:00
delete error from DB when successfully updated
This commit is contained in:
parent
28fa0dec6a
commit
ff25910820
@ -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<Manga, String?>) {
|
||||
val errorMessage = error.second ?: "???"
|
||||
val errorMessageId = insertLibraryUpdateErrorMessages.get(errorMessage)
|
||||
|
@ -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(
|
||||
|
@ -26,3 +26,7 @@ DELETE FROM libraryUpdateError;
|
||||
deleteError:
|
||||
DELETE FROM libraryUpdateError
|
||||
WHERE _id = :_id;
|
||||
|
||||
deleteMangaError:
|
||||
DELETE FROM libraryUpdateError
|
||||
WHERE manga_id = :mangaId;
|
@ -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()
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user