From 10ddeeb7999214f1ed2fa579dadab7e9e379c1a6 Mon Sep 17 00:00:00 2001 From: jmir1 <43830312+jmir1@users.noreply.github.com> Date: Sat, 27 Nov 2021 18:49:26 +0100 Subject: [PATCH] Fix local source cover changing (#6252) * fix local source cover changing * Remove unnecessary check for `exists()` * fix for when there is no thumbnail_url in the db --- .../java/eu/kanade/tachiyomi/source/LocalSource.kt | 13 ++++++------- .../eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt | 2 ++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt b/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt index b87e3a5e74..3f70fccf08 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt @@ -56,15 +56,14 @@ class LocalSource(private val context: Context) : CatalogueSource { if (cover == null) { cover = File("${dir.absolutePath}/${manga.url}", COVER_NAME) } - if (!cover.exists()) { - // It might not exist if using the external SD card - cover.parentFile?.mkdirs() - input.use { - cover.outputStream().use { - input.copyTo(it) - } + // It might not exist if using the external SD card + cover.parentFile?.mkdirs() + input.use { + cover.outputStream().use { + input.copyTo(it) } } + manga.thumbnail_url = cover.absolutePath return cover } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt index 44d989821d..beccee6b99 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt @@ -388,6 +388,8 @@ class MangaPresenter( if (manga.isLocal()) { LocalSource.updateCover(context, manga, it) manga.updateCoverLastModified(db) + db.insertManga(manga).executeAsBlocking() + coverCache.clearMemoryCache() } else if (manga.favorite) { coverCache.setCustomCoverToCache(manga, it) manga.updateCoverLastModified(db)