Crash log no long shows cancelled jobs exceptions for updates

This commit is contained in:
Jay 2020-05-11 16:31:47 -04:00
parent f0b0d3d197
commit 1d3763a34d

View File

@ -40,6 +40,7 @@ import eu.kanade.tachiyomi.util.lang.chop
import eu.kanade.tachiyomi.util.system.executeOnIO import eu.kanade.tachiyomi.util.system.executeOnIO
import eu.kanade.tachiyomi.util.system.notification import eu.kanade.tachiyomi.util.system.notification
import eu.kanade.tachiyomi.util.system.notificationManager import eu.kanade.tachiyomi.util.system.notificationManager
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineExceptionHandler import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.GlobalScope
@ -238,11 +239,15 @@ class LibraryUpdateService(
Timber.e(exception) Timber.e(exception)
} }
GlobalScope.launch(handler) { GlobalScope.launch(handler) {
val hasDLs = requestSemaphore.withPermit { val hasDLs = try {
requestSemaphore.withPermit {
updateMangaInSource( updateMangaInSource(
it.key, downloadNew, categoriesToDownload it.key, downloadNew, categoriesToDownload
) )
} }
} catch (e: Exception) {
false
}
hasDownloads = hasDownloads || hasDLs hasDownloads = hasDownloads || hasDLs
jobCount.andDecrement jobCount.andDecrement
finishUpdates() finishUpdates()
@ -447,7 +452,7 @@ class LibraryUpdateService(
try { try {
var hasDownloads = false var hasDownloads = false
if (job?.isCancelled == true) { if (job?.isCancelled == true) {
throw java.lang.Exception("Job was cancelled") return false
} }
showProgressNotification(manga, progress, mangaToUpdate.size) showProgressNotification(manga, progress, mangaToUpdate.size)
val source = sourceManager.get(manga.source) as? HttpSource ?: return false val source = sourceManager.get(manga.source) as? HttpSource ?: return false
@ -478,7 +483,9 @@ class LibraryUpdateService(
} }
return hasDownloads return hasDownloads
} catch (e: Exception) { } catch (e: Exception) {
if (e !is CancellationException) {
Timber.e("Failed updating: ${manga.title}: $e") Timber.e("Failed updating: ${manga.title}: $e")
}
return false return false
} }
} }