Fix local covers

This commit is contained in:
jmir1 2021-11-21 01:13:43 +01:00
parent 9efbc4ca0f
commit 9df85a6d47
4 changed files with 13 additions and 15 deletions

View file

@ -53,7 +53,6 @@ class LocalAnimeSource(private val context: Context) : AnimeCatalogueSource {
if (cover == null) { if (cover == null) {
cover = File("${dir.absolutePath}/${anime.url}", COVER_NAME) cover = File("${dir.absolutePath}/${anime.url}", COVER_NAME)
} }
if (!cover.exists()) {
// It might not exist if using the external SD card // It might not exist if using the external SD card
cover.parentFile?.mkdirs() cover.parentFile?.mkdirs()
input.use { input.use {
@ -61,7 +60,6 @@ class LocalAnimeSource(private val context: Context) : AnimeCatalogueSource {
input.copyTo(it) input.copyTo(it)
} }
} }
}
return cover return cover
} }
@ -244,7 +242,7 @@ class LocalAnimeSource(private val context: Context) : AnimeCatalogueSource {
private fun getFormat(file: File) = with(file) { private fun getFormat(file: File) = with(file) {
when { when {
isDirectory -> Format.Directory(this) isDirectory -> Format.Directory(this)
SUPPORTED_FILE_TYPES.contains(extension.lowercase(Locale.ENGLISH)) -> Format.Anime(this) isSupportedFile(extension) -> Format.Anime(this.parentFile!!)
else -> throw Exception(context.getString(R.string.local_invalid_episode_format)) else -> throw Exception(context.getString(R.string.local_invalid_episode_format))
} }
} }

View file

@ -56,7 +56,6 @@ class LocalSource(private val context: Context) : CatalogueSource {
if (cover == null) { if (cover == null) {
cover = File("${dir.absolutePath}/${manga.url}", COVER_NAME) cover = File("${dir.absolutePath}/${manga.url}", COVER_NAME)
} }
if (!cover.exists()) {
// It might not exist if using the external SD card // It might not exist if using the external SD card
cover.parentFile?.mkdirs() cover.parentFile?.mkdirs()
input.use { input.use {
@ -64,7 +63,6 @@ class LocalSource(private val context: Context) : CatalogueSource {
input.copyTo(it) input.copyTo(it)
} }
} }
}
return cover return cover
} }

View file

@ -394,6 +394,7 @@ class AnimePresenter(
if (anime.isLocal()) { if (anime.isLocal()) {
LocalAnimeSource.updateCover(context, anime, it) LocalAnimeSource.updateCover(context, anime, it)
anime.updateCoverLastModified(db) anime.updateCoverLastModified(db)
coverCache.clearMemoryCache()
} else if (anime.favorite) { } else if (anime.favorite) {
coverCache.setCustomCoverToCache(anime, it) coverCache.setCustomCoverToCache(anime, it)
anime.updateCoverLastModified(db) anime.updateCoverLastModified(db)

View file

@ -388,6 +388,7 @@ class MangaPresenter(
if (manga.isLocal()) { if (manga.isLocal()) {
LocalSource.updateCover(context, manga, it) LocalSource.updateCover(context, manga, it)
manga.updateCoverLastModified(db) manga.updateCoverLastModified(db)
coverCache.clearMemoryCache()
} else if (manga.favorite) { } else if (manga.favorite) {
coverCache.setCustomCoverToCache(manga, it) coverCache.setCustomCoverToCache(manga, it)
manga.updateCoverLastModified(db) manga.updateCoverLastModified(db)