Skip to content

Commit fa268f1

Browse files
committed
optimize root file size fetching in case we sort by size
1 parent 955f22e commit fa268f1

File tree

1 file changed

+3
-7
lines changed
  • app/src/main/kotlin/com/simplemobiletools/filemanager/helpers

1 file changed

+3
-7
lines changed

app/src/main/kotlin/com/simplemobiletools/filemanager/helpers/RootHelpers.kt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,8 @@ class RootHelpers(val activity: Activity) {
118118

119119
private fun getFileSizes(files: ArrayList<FileDirItem>, path: String, callback: (originalPath: String, fileDirItems: ArrayList<FileDirItem>) -> Unit) {
120120
var cmd = ""
121-
files.forEach {
122-
cmd += if (it.isDirectory) {
123-
"echo 0;"
124-
} else {
125-
"stat -t ${it.path};"
126-
}
121+
files.filter { !it.isDirectory }.forEach {
122+
cmd += "stat -t ${it.path};"
127123
}
128124

129125
val lines = ArrayList<String>()
@@ -134,7 +130,7 @@ class RootHelpers(val activity: Activity) {
134130
}
135131

136132
override fun commandCompleted(id: Int, exitcode: Int) {
137-
files.forEachIndexed { index, fileDirItem ->
133+
files.filter { !it.isDirectory }.forEachIndexed { index, fileDirItem ->
138134
var line = lines[index]
139135
if (line.isNotEmpty() && line != "0") {
140136
if (line.length >= fileDirItem.path.length) {

0 commit comments

Comments
 (0)