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,13 +53,11 @@ class LocalAnimeSource(private val context: Context) : AnimeCatalogueSource {
if (cover == null) {
cover = File("${dir.absolutePath}/${anime.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)
}
}
return cover
@ -244,7 +242,7 @@ class LocalAnimeSource(private val context: Context) : AnimeCatalogueSource {
private fun getFormat(file: File) = with(file) {
when {
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))
}
}

View file

@ -56,13 +56,11 @@ 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)
}
}
return cover

View file

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

View file

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