mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-12 17:08:59 -04:00
#1725 CrashReport 3.1.3: StackOverflowError - use a file walk for extracting all zims under a directory
This commit is contained in:
parent
e043e24465
commit
cb596a44db
@ -71,17 +71,8 @@ class FileSearch @Inject constructor(private val context: Context) {
|
||||
private fun directoryRoots() =
|
||||
StorageDeviceUtils.getReadableStorage(context).map(StorageDevice::name)
|
||||
|
||||
private fun scanDirectory(directory: String): List<File> = File(directory).listFiles()
|
||||
?.fold(
|
||||
mutableListOf(), { acc, file ->
|
||||
acc.apply {
|
||||
if (file.isDirectory) {
|
||||
addAll(scanDirectory(file.path))
|
||||
} else if (file.extension.isAny(*zimFileExtensions)) {
|
||||
add(file)
|
||||
}
|
||||
}
|
||||
}) ?: emptyList()
|
||||
private fun scanDirectory(directory: String): List<File> =
|
||||
File(directory).walk().filter { it.extension.isAny(*zimFileExtensions) }.toList()
|
||||
}
|
||||
|
||||
internal fun String.isAny(vararg suffixes: String) =
|
||||
|
Loading…
x
Reference in New Issue
Block a user