Skip to content

Commit c8e104d

Browse files
committed
fix #403, delete empty folders after move, if really empty
1 parent 919d073 commit c8e104d

File tree

1 file changed

+17
-3
lines changed
  • app/src/main/kotlin/com/simplemobiletools/filemanager/pro/adapters

1 file changed

+17
-3
lines changed

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/adapters/ItemsAdapter.kt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,14 +372,28 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
372372
private fun copyMoveTo(isCopyOperation: Boolean) {
373373
val files = getSelectedFileDirItems()
374374
val firstFile = files[0]
375-
val source = if (firstFile.isDirectory) firstFile.path else firstFile.getParentPath()
375+
val source = firstFile.getParentPath()
376376
FilePickerDialog(activity, source, false, activity.config.shouldShowHidden, true, true, showFavoritesButton = true) {
377377
if (activity.isPathOnRoot(it) || activity.isPathOnRoot(firstFile.path)) {
378378
copyMoveRootItems(files, it, isCopyOperation)
379379
} else {
380380
activity.copyMoveFilesTo(files, source, it, isCopyOperation, false, activity.config.shouldShowHidden) {
381-
listener?.refreshItems()
382-
finishActMode()
381+
if (!isCopyOperation) {
382+
files.forEach { sourceFileDir ->
383+
val sourceFile = File(sourceFileDir.path)
384+
if (activity.getDoesFilePathExist(source) && activity.getIsPathDirectory(source) &&
385+
sourceFile.list()?.isEmpty() == true && sourceFile.getProperSize(true) == 0L && sourceFile.getFileCount(true) == 0) {
386+
val sourceFolder = sourceFile.toFileDirItem(activity)
387+
activity.deleteFile(sourceFolder, true) {
388+
listener?.refreshItems()
389+
finishActMode()
390+
}
391+
}
392+
}
393+
} else {
394+
listener?.refreshItems()
395+
finishActMode()
396+
}
383397
}
384398
}
385399
}

0 commit comments

Comments
 (0)