fix #403, delete empty folders after move, if really empty

This commit is contained in:
tibbi 2021-01-23 17:36:15 +01:00
parent 919d073a03
commit c8e104d88d
1 changed files with 17 additions and 3 deletions

View File

@ -372,14 +372,28 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
private fun copyMoveTo(isCopyOperation: Boolean) {
val files = getSelectedFileDirItems()
val firstFile = files[0]
val source = if (firstFile.isDirectory) firstFile.path else firstFile.getParentPath()
val source = firstFile.getParentPath()
FilePickerDialog(activity, source, false, activity.config.shouldShowHidden, true, true, showFavoritesButton = true) {
if (activity.isPathOnRoot(it) || activity.isPathOnRoot(firstFile.path)) {
copyMoveRootItems(files, it, isCopyOperation)
} else {
activity.copyMoveFilesTo(files, source, it, isCopyOperation, false, activity.config.shouldShowHidden) {
listener?.refreshItems()
finishActMode()
if (!isCopyOperation) {
files.forEach { sourceFileDir ->
val sourceFile = File(sourceFileDir.path)
if (activity.getDoesFilePathExist(source) && activity.getIsPathDirectory(source) &&
sourceFile.list()?.isEmpty() == true && sourceFile.getProperSize(true) == 0L && sourceFile.getFileCount(true) == 0) {
val sourceFolder = sourceFile.toFileDirItem(activity)
activity.deleteFile(sourceFolder, true) {
listener?.refreshItems()
finishActMode()
}
}
}
} else {
listener?.refreshItems()
finishActMode()
}
}
}
}