From ac8f2923e5fa5fda5605f7f1f50961ea49b04b54 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 23 May 2020 15:19:17 -0400 Subject: [PATCH] Handle empty thumbnail_url when refreshing covers --- .../eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt | 4 ++-- app/src/main/java/eu/kanade/tachiyomi/util/MangaExtensions.kt | 3 +++ 2 files changed, 5 insertions(+), 2 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 9dab85fe6..3fa56fda8 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 @@ -337,8 +337,8 @@ class LibraryUpdateService( if (preferences.autoUpdateMetadata()) { source.fetchMangaDetails(manga) .map { updatedManga -> - // Avoid "losing" covers - if (updatedManga.thumbnail_url != null) { + // Avoid "losing" existing cover + if (!updatedManga.thumbnail_url.isNullOrEmpty()) { manga.prepUpdateCover(coverCache, updatedManga, false) } else { updatedManga.thumbnail_url = manga.thumbnail_url diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/MangaExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/MangaExtensions.kt index 9dcadcfec..e4d4419e8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/MangaExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/MangaExtensions.kt @@ -17,6 +17,9 @@ fun Manga.prepUpdateCover(coverCache: CoverCache, remoteManga: SManga, refreshSa // Never refresh covers if the new url is null, as the current url has possibly become invalid val newUrl = remoteManga.thumbnail_url ?: return + // Never refresh covers if the url is empty to avoid "losing" existing covers + if (newUrl.isEmpty()) return + if (!refreshSameUrl && thumbnail_url == newUrl) return when {