Fix random page sent when manga is downloaded (#508)

This commit is contained in:
akabhirav
2023-02-21 04:40:38 +05:30
committed by GitHub
parent c56f984952
commit ac99dd55a2
2 changed files with 1 additions and 2 deletions
@@ -33,7 +33,6 @@ class ArchiveProvider(mangaId: Int, chapterId: Int) : DownloadedFilesProvider(ma
val chapterFolder = File(chapterDir)
if (outputFile.exists()) handleExistingCbzFile(outputFile, chapterFolder)
FolderProvider(mangaId, chapterId).download(download, scope, step)
withContext(Dispatchers.IO) {
@@ -24,7 +24,7 @@ class FolderProvider(mangaId: Int, chapterId: Int) : DownloadedFilesProvider(man
val chapterDir = getChapterDownloadPath(mangaId, chapterId)
val folder = File(chapterDir)
folder.mkdirs()
val file = folder.listFiles()?.get(index)
val file = folder.listFiles()?.sortedBy { it.name }?.get(index)
val fileType = file!!.name.substringAfterLast(".")
return Pair(FileInputStream(file).buffered(), "image/$fileType")
}