From 19668088a84595977b140b55072aaa86baf591c1 Mon Sep 17 00:00:00 2001 From: Naveen Date: Sat, 16 Mar 2024 01:11:24 +0530 Subject: [PATCH] Disable manual storage scanning Closes https://github.com/FossifyOrg/File-Manager/issues/28 When there are more than a few files on the SD Card, this can lead to a busy media scanner situation where any further calls to scan a file are scheduled to be executed after the initial scan is complete. As a result, simple actions like rename (which trigger a rescan) can take a long time to complete. Originally added in https://github.com/SimpleMobileTools/Simple-File-Manager/commit/4cca280de7bdae5c2a2d20d6c93ead2047c6df67 to fix issues related to stale SD Card stats but it doesn't seem necessary as per my testing. --- .../filemanager/fragments/StorageFragment.kt | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/app/src/main/kotlin/org/fossify/filemanager/fragments/StorageFragment.kt b/app/src/main/kotlin/org/fossify/filemanager/fragments/StorageFragment.kt index be57a140..b0804aed 100644 --- a/app/src/main/kotlin/org/fossify/filemanager/fragments/StorageFragment.kt +++ b/app/src/main/kotlin/org/fossify/filemanager/fragments/StorageFragment.kt @@ -6,7 +6,6 @@ import android.app.usage.StorageStatsManager import android.content.ContentResolver import android.content.Context import android.content.Intent -import android.media.MediaScannerConnection import android.os.Handler import android.os.Looper import android.os.storage.StorageManager @@ -33,7 +32,6 @@ import org.fossify.filemanager.extensions.getAllVolumeNames import org.fossify.filemanager.helpers.* import org.fossify.filemanager.interfaces.ItemOperationsListener import org.fossify.filemanager.models.ListItem -import java.io.File import java.util.Locale class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), @@ -299,11 +297,6 @@ class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPage volumeName = storageVolume.uuid!!.lowercase(Locale.US) totalStorageSpace = file.totalSpace freeStorageSpace = file.freeSpace - post { - ensureBackgroundThread { - scanVolume(volumeName, file) - } - } } post { @@ -326,22 +319,6 @@ class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPage } } - private fun scanVolume(volumeName: String, root: File) { - val paths = mutableListOf() - if (context.isPathOnSD(root.path)) { - File(context.sdCardPath).walkBottomUp().forEach { - paths.add(it.path) - } - } - var callbackCount = 0 - MediaScannerConnection.scanFile(context, paths.toTypedArray(), null) { _, _ -> - callbackCount++ - if (callbackCount == paths.size) { - getSizes(volumeName) - } - } - } - override fun searchQueryChanged(text: String) { lastSearchedText = text binding.apply {