From 1d3763a34dfa369efcc69f4a9c5ef70bf5af8680 Mon Sep 17 00:00:00 2001 From: Jay Date: Mon, 11 May 2020 16:31:47 -0400 Subject: [PATCH] Crash log no long shows cancelled jobs exceptions for updates --- .../data/library/LibraryUpdateService.kt | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt index 3f19ea4dcc..b35342e4b8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt @@ -40,6 +40,7 @@ import eu.kanade.tachiyomi.util.lang.chop import eu.kanade.tachiyomi.util.system.executeOnIO import eu.kanade.tachiyomi.util.system.notification import eu.kanade.tachiyomi.util.system.notificationManager +import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineExceptionHandler import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope @@ -238,10 +239,14 @@ class LibraryUpdateService( Timber.e(exception) } GlobalScope.launch(handler) { - val hasDLs = requestSemaphore.withPermit { - updateMangaInSource( - it.key, downloadNew, categoriesToDownload - ) + val hasDLs = try { + requestSemaphore.withPermit { + updateMangaInSource( + it.key, downloadNew, categoriesToDownload + ) + } + } catch (e: Exception) { + false } hasDownloads = hasDownloads || hasDLs jobCount.andDecrement @@ -447,7 +452,7 @@ class LibraryUpdateService( try { var hasDownloads = false if (job?.isCancelled == true) { - throw java.lang.Exception("Job was cancelled") + return false } showProgressNotification(manga, progress, mangaToUpdate.size) val source = sourceManager.get(manga.source) as? HttpSource ?: return false @@ -478,7 +483,9 @@ class LibraryUpdateService( } return hasDownloads } catch (e: Exception) { - Timber.e("Failed updating: ${manga.title}: $e") + if (e !is CancellationException) { + Timber.e("Failed updating: ${manga.title}: $e") + } return false } }