Massively improve findFile performance (#728)

* Massively improve findFile performance

* Update libs.versions.toml

---------

Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
(cherry picked from commit 7ec2108812fbe0483111dbe996e29e5a621b583a)
This commit is contained in:
Radon Rosborough
2024-05-04 09:40:41 -07:00
committed by Jobobby04
parent 712cd1493f
commit 089e6268e7
6 changed files with 11 additions and 11 deletions
@@ -368,8 +368,8 @@ actual class LocalSource(
try {
val (mangaDirName, chapterName) = chapter.url.split('/', limit = 2)
return fileSystem.getBaseDirectory()
?.findFile(mangaDirName, true)
?.findFile(chapterName, true)
?.findFile(mangaDirName)
?.findFile(chapterName)
?.let(Format.Companion::valueOf)
?: throw Exception(context.stringResource(MR.strings.chapter_not_found))
} catch (e: Format.UnknownFormatException) {
@@ -17,13 +17,13 @@ actual class LocalSourceFileSystem(
actual fun getMangaDirectory(name: String): UniFile? {
return getBaseDirectory()
?.findFile(name, true)
?.findFile(name)
?.takeIf { it.isDirectory }
}
actual fun getFilesInMangaDirectory(name: String): List<UniFile> {
return getBaseDirectory()
?.findFile(name, true)
?.findFile(name)
?.takeIf { it.isDirectory }
?.listFiles().orEmpty().toList()
}