DBZ-1621 Fix IoUtil.createDirectory parameter removeExistingContent is not take effect

This commit is contained in:
pan3793 2019-11-19 09:02:40 +08:00 committed by Gunnar Morling
parent 89fde5ce06
commit 91f0c2a520

View File

@ -371,7 +371,9 @@ public static File createDirectory(Path path, boolean removeExistingContent) thr
File dir = path.toAbsolutePath().toFile();
if (dir.exists() && dir.canRead() && dir.canWrite()) {
if (dir.isDirectory()) {
delete(path);
if (removeExistingContent) {
delete(path);
}
return dir;
}
throw new IllegalStateException("Expecting '" + path + "' to be a directory but found a file");