From 3ad24840a3a30aefa4780279b6f58b76a9afb912 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Thu, 6 May 2021 15:34:02 -0400 Subject: [PATCH] Fix coil key for manga with same thumbnail Since we're using the same thumbnail url for all md entries right now --- .../java/eu/kanade/tachiyomi/data/cache/CoverCache.kt | 11 ++++------- .../eu/kanade/tachiyomi/data/database/models/Manga.kt | 3 +-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/cache/CoverCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/cache/CoverCache.kt index 06152edf0a..0c1ba824ec 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/cache/CoverCache.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/cache/CoverCache.kt @@ -71,7 +71,7 @@ class CoverCache(val context: Context) { val db = Injekt.get() var deletedSize = 0L val urls = db.getLibraryMangas().executeOnIO().mapNotNull { - it.thumbnail_url?.let { url -> return@mapNotNull it.key() } + it.thumbnail_url?.let { url -> return@mapNotNull DiskUtil.hashKeyForDisk(url) } null } val files = cacheDir.listFiles()?.iterator() ?: return@launch @@ -200,17 +200,14 @@ class CoverCache(val context: Context) { * @return cover image. */ fun getCoverFile(manga: Manga): File { + val hashKey = DiskUtil.hashKeyForDisk((manga.thumbnail_url.orEmpty())) return if (manga.favorite) { - File(cacheDir, manga.key()) + File(cacheDir, hashKey) } else { - getOnlineCoverFile(manga) + File(onlineCoverDirectory, hashKey) } } - fun getOnlineCoverFile(manga: Manga): File { - return File(onlineCoverDirectory, manga.key()) - } - fun deleteFromCache(name: String?) { if (name.isNullOrEmpty()) return val file = getCoverFile(MangaImpl().apply { thumbnail_url = name }) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.kt index 9a59be0966..c0056888aa 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.kt @@ -5,7 +5,6 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.ui.reader.ReaderActivity -import eu.kanade.tachiyomi.util.storage.DiskUtil import tachiyomi.source.model.MangaInfo import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get @@ -190,7 +189,7 @@ interface Manga : SManga { } fun key(): String { - return DiskUtil.hashKeyForDisk(thumbnail_url.orEmpty()) + return "manga-id-$id" } // Used to display the chapter's title one way or another