Skip to content

Commit 1966808

Browse files
committed
Disable manual storage scanning
Closes #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 SimpleMobileTools/Simple-File-Manager@4cca280 to fix issues related to stale SD Card stats but it doesn't seem necessary as per my testing.
1 parent 1a422ae commit 1966808

File tree

1 file changed

+0
-23
lines changed

1 file changed

+0
-23
lines changed

app/src/main/kotlin/org/fossify/filemanager/fragments/StorageFragment.kt

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import android.app.usage.StorageStatsManager
66
import android.content.ContentResolver
77
import android.content.Context
88
import android.content.Intent
9-
import android.media.MediaScannerConnection
109
import android.os.Handler
1110
import android.os.Looper
1211
import android.os.storage.StorageManager
@@ -33,7 +32,6 @@ import org.fossify.filemanager.extensions.getAllVolumeNames
3332
import org.fossify.filemanager.helpers.*
3433
import org.fossify.filemanager.interfaces.ItemOperationsListener
3534
import org.fossify.filemanager.models.ListItem
36-
import java.io.File
3735
import java.util.Locale
3836

3937
class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment<MyViewPagerFragment.StorageInnerBinding>(context, attributeSet),
@@ -299,11 +297,6 @@ class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
299297
volumeName = storageVolume.uuid!!.lowercase(Locale.US)
300298
totalStorageSpace = file.totalSpace
301299
freeStorageSpace = file.freeSpace
302-
post {
303-
ensureBackgroundThread {
304-
scanVolume(volumeName, file)
305-
}
306-
}
307300
}
308301

309302
post {
@@ -326,22 +319,6 @@ class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
326319
}
327320
}
328321

329-
private fun scanVolume(volumeName: String, root: File) {
330-
val paths = mutableListOf<String>()
331-
if (context.isPathOnSD(root.path)) {
332-
File(context.sdCardPath).walkBottomUp().forEach {
333-
paths.add(it.path)
334-
}
335-
}
336-
var callbackCount = 0
337-
MediaScannerConnection.scanFile(context, paths.toTypedArray(), null) { _, _ ->
338-
callbackCount++
339-
if (callbackCount == paths.size) {
340-
getSizes(volumeName)
341-
}
342-
}
343-
}
344-
345322
override fun searchQueryChanged(text: String) {
346323
lastSearchedText = text
347324
binding.apply {

0 commit comments

Comments
 (0)