From 3a82b4d924ae7207f7d1c1b23d2a71a1e7d09258 Mon Sep 17 00:00:00 2001 From: Two-Ai <81279822+Two-Ai@users.noreply.github.com> Date: Wed, 25 Jan 2023 18:18:17 -0500 Subject: [PATCH] Don't crash on timeout in renewCache() (#8986) Fixes #8962. withTimeout throws a TimeoutCancellationException if the timeout expires. To avoid crashing renewalJob when there are no extensions, use withTimeoutOrNull which does not throw on timeout. --- .../java/eu/kanade/tachiyomi/data/download/DownloadCache.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 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 842a36651..623f8ebb3 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 @@ -28,7 +28,7 @@ import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.flow.receiveAsFlow import kotlinx.coroutines.flow.shareIn import kotlinx.coroutines.flow.stateIn -import kotlinx.coroutines.withTimeout +import kotlinx.coroutines.withTimeoutOrNull import logcat.LogPriority import tachiyomi.domain.chapter.model.Chapter import tachiyomi.domain.manga.model.Manga @@ -276,7 +276,7 @@ class DownloadCache( var sources = getSources() // Try to wait until extensions and sources have loaded - withTimeout(30.seconds) { + withTimeoutOrNull(30.seconds) { while (!extensionManager.isInitialized) { delay(2.seconds) }