Avoid auto-deleting empty structure root folders (e.g. Media, Staging, etc)
This commit is contained in:
parent
94c830c93a
commit
d61695b426
|
@ -164,23 +164,22 @@ class RenameAction extends AbstractAction {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// guess affected folder depth
|
|
||||||
int relativePathSize = 0;
|
|
||||||
try {
|
try {
|
||||||
relativePathSize = listStructurePathTail(s).size();
|
// guess affected folder depth
|
||||||
|
int tailSize = listStructurePathTail(s).size();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
stream(children).forEach(empty::add);
|
||||||
|
empty.add(sourceFolder);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
debug.warning(e::toString);
|
debug.warning(e::toString);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < relativePathSize && !isVolumeRoot(sourceFolder); sourceFolder = sourceFolder.getParentFile(), i++) {
|
|
||||||
File[] children = sourceFolder.listFiles();
|
|
||||||
if (children == null || !stream(children).allMatch(f -> empty.contains(f) || f.isHidden())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
stream(children).forEach(empty::add);
|
|
||||||
empty.add(sourceFolder);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
for (File f : empty) {
|
for (File f : empty) {
|
||||||
|
|
Loading…
Reference in New Issue