Avoid auto-deleting empty structure root folders (e.g. Media, Staging, etc)

This commit is contained in:
Reinhard Pointner 2016-05-06 19:39:00 +08:00
parent 94c830c93a
commit d61695b426
1 changed files with 12 additions and 13 deletions

View File

@ -164,15 +164,11 @@ class RenameAction extends AbstractAction {
return;
}
// guess affected folder depth
int relativePathSize = 0;
try {
relativePathSize = listStructurePathTail(s).size();
} catch (Exception e) {
debug.warning(e::toString);
}
// guess affected folder depth
int tailSize = listStructurePathTail(s).size();
for (int i = 0; i < relativePathSize && !isVolumeRoot(sourceFolder); sourceFolder = sourceFolder.getParentFile(), i++) {
for (int i = 0; i < tailSize && !isStructureRoot(sourceFolder); sourceFolder = sourceFolder.getParentFile(), i++) {
File[] children = sourceFolder.listFiles();
if (children == null || !stream(children).allMatch(f -> empty.contains(f) || f.isHidden())) {
return;
@ -181,6 +177,9 @@ class RenameAction extends AbstractAction {
stream(children).forEach(empty::add);
empty.add(sourceFolder);
}
} catch (Exception e) {
debug.warning(e::toString);
}
});
for (File f : empty) {