From cbee2b970d151c3d6462cc556be72100c41552c1 Mon Sep 17 00:00:00 2001 From: Sean Mac Gillicuddy Date: Thu, 9 Jan 2020 15:24:39 +0000 Subject: [PATCH] #1663 Improve FileSystem detection - prevent infinite recursion by removing visited entries - add vfat to <4GB filesystems --- .../zim_manager/MountFileSystemChecker.kt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/MountFileSystemChecker.kt b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/MountFileSystemChecker.kt index d7adcb7ef..dd5a9bf10 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/MountFileSystemChecker.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/MountFileSystemChecker.kt @@ -27,15 +27,13 @@ class MountFileSystemChecker : FileSystemChecker { override fun checkFilesystemSupports4GbFiles(path: String) = recursivelyDetermineFilesystem(mountPoints(), path) - private fun recursivelyDetermineFilesystem( - mountPoints: List, - path: String - ): FileSystemCapability = + private fun recursivelyDetermineFilesystem(mountPoints: List, path: String): + FileSystemCapability = mountPoints.maxBy { it.matchCount(path) } ?.takeIf { it.matchCount(path) > 0 } ?.let { when { - it.isVirtual -> recursivelyDetermineFilesystem(mountPoints, it.device) + it.isVirtual -> recursivelyDetermineFilesystem(mountPoints - it, it.device) it.supports4GBFiles -> CAN_WRITE_4GB it.doesNotSupport4GBFiles -> CANNOT_WRITE_4GB else -> INCONCLUSIVE @@ -65,8 +63,8 @@ data class MountInfo(val device: String, val mountPoint: String, val fileSystem: val doesNotSupport4GBFiles = DOES_NOT_SUPPORT_4GB_FILE_SYSTEMS.contains(fileSystem) companion object { - private val VIRTUAL_FILE_SYSTEMS = listOf("fuse", "sdcardfs", "tmpfs") + private val VIRTUAL_FILE_SYSTEMS = listOf("fuse", "sdcardfs") private val SUPPORTS_4GB_FILE_SYSTEMS = listOf("ext4", "exfat") - private val DOES_NOT_SUPPORT_4GB_FILE_SYSTEMS = listOf("fat32") + private val DOES_NOT_SUPPORT_4GB_FILE_SYSTEMS = listOf("fat32", "vfat") } }