cyrus-jackson commented on a change in pull request #148:
URL: https://github.com/apache/incubator-ratis/pull/148#discussion_r465463557
##########
File path: ratis-common/src/main/java/org/apache/ratis/util/FileUtils.java
##########
@@ -85,6 +85,43 @@ static void deleteFile(File f) throws IOException {
delete(f.toPath());
}
+ /**
+ * Moves the directory. If any file is locked, the exception is caught
+ * and logged and continues to other files.
+ * @param source
+ * @param dest
+ * @throws IOException
+ */
+ static void moveDirectory(Path source, Path dest) throws IOException {
+ LOG.trace("moveDirectory source: {} dest: {}", source, dest);
+ createDirectories(dest);
+ Files.walkFileTree(source, new SimpleFileVisitor<Path>() {
+ @Override
+ public FileVisitResult preVisitDirectory(Path dir,
+ BasicFileAttributes attrs) throws IOException {
+ Path targetPath = dest.resolve(source.relativize(dir));
+ if (!Files.exists(targetPath)) {
+ createDirectories(targetPath);
+ }
Review comment:
This call is required for sub folders, otherwise only the files get
copied.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]