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.
This commit is contained in:
Naveen committed 2024-03-16 03:48:33 +05:30
1 parent 1a422ae262
commit 19668088a8
1 file changed
-23
@@ -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<MyViewPagerFragment.StorageInnerBinding>(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<String>()
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 {