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 4cca280de7 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
2024-03-16 01:11:24 +05:30
parent 1a422ae262
commit 19668088a8

View File

@@ -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 {