Avoid catastrophic failure when cover can't be created in local source

Co-Authored-By: arkon <4098258+arkon@users.noreply.github.com>
This commit is contained in:
Jays2Kings 2022-08-21 01:21:31 -04:00
parent d236536e86
commit d64932a504

View file

@ -313,7 +313,8 @@ class LocalSource(private val context: Context) : CatalogueSource, UnmeteredSour
}
private fun updateCover(chapter: SChapter, manga: SManga): File? {
return when (val format = getFormat(chapter)) {
return try {
when (val format = getFormat(chapter)) {
is Format.Directory -> {
val entry = format.file.listFiles()
?.sortedWith { f1, f2 -> f1.name.compareToCaseInsensitiveNaturalOrder(f2.name) }
@ -349,6 +350,10 @@ class LocalSource(private val context: Context) : CatalogueSource, UnmeteredSour
}
}
}
} catch (e: Throwable) {
Timber.e(e, "Error updating cover for ${manga.title}")
null
}
}
override fun getFilterList() = popularFilters