From b6d6de6b9f80798c5b363f7e361de073db4a6d55 Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 5 Dec 2022 22:18:19 -0500 Subject: [PATCH] Avoid crashing when clearing cookies for invalid source URLs e.g. Komga sources with no URLs set --- .../extension/details/ExtensionDetailsScreenModel.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsScreenModel.kt index 32c5f4552..fc2109d2b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsScreenModel.kt @@ -115,11 +115,16 @@ class ExtensionDetailsScreenModel( val urls = extension.sources .filterIsInstance() - .map { it.baseUrl } + .mapNotNull { it.baseUrl.takeUnless { url -> url.isEmpty() } } .distinct() val cleared = urls.sumOf { - network.cookieManager.remove(it.toHttpUrl()) + try { + network.cookieManager.remove(it.toHttpUrl()) + } catch (e: Exception) { + logcat(LogPriority.ERROR, e) { "Failed to clear cookies for $it" } + 0 + } } logcat { "Cleared $cleared cookies for: ${urls.joinToString()}" }