Fixed bug in FilesystemUtils.copyAndReplaceDirectory()

This commit is contained in:
CalDescent 2021-08-15 21:50:19 +01:00
parent c7d88ed95b
commit b46c328811

View File

@ -29,6 +29,12 @@ public class FilesystemUtils {
throw new IOException("Destination directory doesn't exist"); throw new IOException("Destination directory doesn't exist");
} }
// If the destination directory isn't empty, delete its contents
if (!FilesystemUtils.isDirectoryEmpty(destFile.toPath())) {
FileUtils.deleteDirectory(destFile);
destFile.mkdirs();
}
Files.walk(Paths.get(sourceDirectoryLocation)) Files.walk(Paths.get(sourceDirectoryLocation))
.forEach(source -> { .forEach(source -> {
Path destination = Paths.get(destinationDirectoryLocation, source.toString() Path destination = Paths.get(destinationDirectoryLocation, source.toString()