Fixed #1409 by addig an additonal check

This commit is contained in:
JaniruTEC
2020-11-18 00:46:24 +01:00
parent 9f61ad1941
commit 9083976989

View File

@@ -48,6 +48,7 @@ public class IrregularUnmountCleaner {
private static void deleteEmptyDir(Path dir) throws IOException {
assert Files.isDirectory(dir, LinkOption.NOFOLLOW_LINKS);
try {
checkEmpty(dir);
Files.delete(dir); // attempt to delete dir non-recursively (will fail, if there are contents)
} catch (DirectoryNotEmptyException e) {
LOG.info("Found non-empty directory in mountpoint dir: {}", dir);
@@ -61,4 +62,10 @@ public class IrregularUnmountCleaner {
}
}
private static void checkEmpty(Path dir) throws IOException {
if(Files.newDirectoryStream(dir).iterator().hasNext()) {
throw new DirectoryNotEmptyException(dir.toString());
}
}
}