forked from hardcoresushi/DroidFS
More accurate directory size
This commit is contained in:
parent
e01b5a3098
commit
58391802be
@ -228,6 +228,15 @@ open class BaseExplorerActivity : BaseActivity() {
|
|||||||
sharedPrefsEditor.apply()
|
sharedPrefsEditor.apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun recursiveSetSize(directory: ExplorerElement) {
|
||||||
|
for (child in gocryptfsVolume.listDir(directory.fullPath)) {
|
||||||
|
if (child.isDirectory) {
|
||||||
|
recursiveSetSize(child)
|
||||||
|
}
|
||||||
|
directory.size += child.size
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected fun setCurrentPath(path: String, onDisplayed: (() -> Unit)? = null) {
|
protected fun setCurrentPath(path: String, onDisplayed: (() -> Unit)? = null) {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
explorerElements = gocryptfsVolume.listDir(path)
|
explorerElements = gocryptfsVolume.listDir(path)
|
||||||
@ -247,19 +256,11 @@ open class BaseExplorerActivity : BaseActivity() {
|
|||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
for (element in explorerElements) {
|
for (element in explorerElements) {
|
||||||
if (element.isDirectory) {
|
if (element.isDirectory) {
|
||||||
var dirSize: Long = 0
|
recursiveSetSize(element)
|
||||||
for (subFile in gocryptfsVolume.recursiveMapFiles(element.fullPath)){
|
|
||||||
if (subFile.isRegularFile){
|
|
||||||
dirSize += subFile.size
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
element.size = dirSize
|
|
||||||
totalSize += dirSize
|
|
||||||
} else if (element.isRegularFile) {
|
|
||||||
totalSize += element.size
|
totalSize += element.size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
val totalSizeValue = PathUtils.formatSize(totalSize)
|
val totalSizeValue = PathUtils.formatSize(totalSize)
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
displayExplorerElements(totalSizeValue)
|
displayExplorerElements(totalSizeValue)
|
||||||
|
Loading…
Reference in New Issue
Block a user