From 235bc7745734fdda4cbcfe42452d611e8fa6693c Mon Sep 17 00:00:00 2001 From: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> Date: Sat, 17 Dec 2022 22:32:49 +0700 Subject: [PATCH] Fix indexing notif not showing (#8758) --- .../tachiyomi/data/download/DownloadCache.kt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt index 4f90943c65..3c5dc6a572 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt @@ -12,6 +12,8 @@ import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.util.lang.launchIO import eu.kanade.tachiyomi.util.lang.launchNonCancellable +import eu.kanade.tachiyomi.util.system.logcat +import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -29,6 +31,7 @@ import kotlinx.coroutines.flow.receiveAsFlow import kotlinx.coroutines.flow.shareIn import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.withTimeout +import logcat.LogPriority import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import java.util.concurrent.ConcurrentHashMap @@ -319,10 +322,18 @@ class DownloadCache( } } .awaitAll() - - lastRenew = System.currentTimeMillis() - notifyChanges() + }.also { + it.invokeOnCompletion(onCancelling = true) { exception -> + if (exception != null && exception !is CancellationException) { + logcat(LogPriority.ERROR, exception) { "Failed to create download cache" } + } + lastRenew = System.currentTimeMillis() + notifyChanges() + } } + + // Mainly to notify the indexing notifier UI + notifyChanges() } private fun getSources(): List {