Fix coil key for manga with same thumbnail

Since we're using the same thumbnail url for all md entries right now
This commit is contained in:
Jays2Kings 2021-05-06 15:34:02 -04:00
parent 627ea5fe33
commit 3ad24840a3
2 changed files with 5 additions and 9 deletions

View File

@ -71,7 +71,7 @@ class CoverCache(val context: Context) {
val db = Injekt.get<DatabaseHelper>()
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 })

View File

@ -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