fix: Check if chapterFile is directory before getting ComicInfo

This commit is contained in:
Ahmad Ansori Palembani 2024-05-31 10:48:41 +07:00
parent b87cbc87d6
commit da1b9abe2a
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6

View file

@ -282,9 +282,12 @@ class LocalSource(private val context: Context) : CatalogueSource, UnmeteredSour
val chapters = getBaseDirectory().findFile(manga.url)?.listFiles().orEmpty()
.filter { it.isDirectory || isSupportedFile(it.extension.orEmpty()) }
.map { chapterFile ->
val chapterComicInfo = chapterFile.findFile(COMIC_INFO_FILE)?.let {
decodeComicInfo(it.openInputStream(), xml)
}
val chapterComicInfo =
if (chapterFile.isDirectory)
chapterFile.findFile(COMIC_INFO_FILE)?.let {
decodeComicInfo(it.openInputStream(), xml)
}
else null
SChapter.create().apply {
url = "${manga.url}/${chapterFile.name}"