Ignore casing when looking for some files/folders

This commit is contained in:
arkon 2023-11-28 08:59:34 -05:00
parent a74a689c90
commit e41668862f
4 changed files with 4 additions and 5 deletions

View file

@ -27,7 +27,6 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.core.net.toUri import androidx.core.net.toUri
import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.LocalNavigator
import cafe.adriel.voyager.navigator.currentOrThrow import cafe.adriel.voyager.navigator.currentOrThrow

View file

@ -91,7 +91,7 @@ class DownloadProvider(
val mangaDir = findMangaDir(manga.title, source) ?: return null to emptyList() val mangaDir = findMangaDir(manga.title, source) ?: return null to emptyList()
return mangaDir to chapters.mapNotNull { chapter -> return mangaDir to chapters.mapNotNull { chapter ->
getValidChapterDirNames(chapter.name, chapter.scanlator).asSequence() getValidChapterDirNames(chapter.name, chapter.scanlator).asSequence()
.mapNotNull { mangaDir.findFile(it) } .mapNotNull { mangaDir.findFile(it, true) }
.firstOrNull() .firstOrNull()
} }
} }

View file

@ -642,7 +642,7 @@ class Downloader(
val categories = getCategories.await(manga.id).map { it.name.trim() }.takeUnless { it.isEmpty() } val categories = getCategories.await(manga.id).map { it.name.trim() }.takeUnless { it.isEmpty() }
val comicInfo = getComicInfo(manga, chapter, chapterUrl, categories) val comicInfo = getComicInfo(manga, chapter, chapterUrl, categories)
// Remove the old file // Remove the old file
dir.findFile(COMIC_INFO_FILE)?.delete() dir.findFile(COMIC_INFO_FILE, true)?.delete()
dir.createFile(COMIC_INFO_FILE)!!.openOutputStream().use { dir.createFile(COMIC_INFO_FILE)!!.openOutputStream().use {
val comicInfoString = xml.encodeToString(ComicInfo.serializer(), comicInfo) val comicInfoString = xml.encodeToString(ComicInfo.serializer(), comicInfo)
it.write(comicInfoString.toByteArray()) it.write(comicInfoString.toByteArray())

View file

@ -303,8 +303,8 @@ actual class LocalSource(
try { try {
val (mangaDirName, chapterName) = chapter.url.split('/', limit = 2) val (mangaDirName, chapterName) = chapter.url.split('/', limit = 2)
return fileSystem.getBaseDirectory() return fileSystem.getBaseDirectory()
?.findFile(mangaDirName) ?.findFile(mangaDirName, true)
?.findFile(chapterName) ?.findFile(chapterName, true)
?.let(Format.Companion::valueOf) ?.let(Format.Companion::valueOf)
?: throw Exception(context.stringResource(MR.strings.chapter_not_found)) ?: throw Exception(context.stringResource(MR.strings.chapter_not_found))
} catch (e: Format.UnknownFormatException) { } catch (e: Format.UnknownFormatException) {