Use unified storage location for local source

This commit is contained in:
arkon
2023-11-25 17:06:15 -05:00
parent 21ae04d25d
commit cf9e60fd92
6 changed files with 19 additions and 49 deletions

View File

@ -73,7 +73,7 @@ actual class LocalSource(
override suspend fun getLatestUpdates(page: Int) = getSearchManga(page, "", LATEST_FILTERS)
override suspend fun getSearchManga(page: Int, query: String, filters: FilterList): MangasPage {
val baseDirsFiles = fileSystem.getFilesInBaseDirectories()
val baseDirFiles = fileSystem.getFilesInBaseDirectory()
val lastModifiedLimit by lazy {
if (filters === LATEST_FILTERS) {
System.currentTimeMillis() - LATEST_THRESHOLD
@ -81,7 +81,7 @@ actual class LocalSource(
0L
}
}
var mangaDirs = baseDirsFiles
var mangaDirs = baseDirFiles
// Filter out files that are hidden and is not a folder
.filter { it.isDirectory && !it.name.startsWith('.') }
.distinctBy { it.name }
@ -308,9 +308,8 @@ actual class LocalSource(
fun getFormat(chapter: SChapter): Format {
try {
return fileSystem.getBaseDirectories()
.map { dir -> File(dir, chapter.url) }
.find { it.exists() }
return File(fileSystem.getBaseDirectory(), chapter.url)
.takeIf { it.exists() }
?.let(Format.Companion::valueOf)
?: throw Exception(context.stringResource(MR.strings.chapter_not_found))
} catch (e: Format.UnknownFormatException) {