Skip to content

Commit

Permalink
Fix purge output directory issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bowbahdoe committed Aug 24, 2024
1 parent c5511e9 commit 7a3586d
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions src/main/java/dev/mccue/resolve/cli/CliMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -514,26 +514,31 @@ protected PasswordAuthentication getPasswordAuthentication() {
}

if (outputDirectory != null && purgeOutputDirectory) {
Files.walkFileTree(outputDirectory.toPath(), new SimpleFileVisitor<>() {
@Override
public FileVisitResult visitFile(Path file,
BasicFileAttributes attrs) throws IOException {
Files.delete(file);
return FileVisitResult.CONTINUE;
}

@Override
public FileVisitResult postVisitDirectory(Path dir,
IOException e) throws IOException {
if (e == null) {
Files.delete(dir);
try {
Files.walkFileTree(outputDirectory.toPath(), new SimpleFileVisitor<>() {
@Override
public FileVisitResult visitFile(Path file,
BasicFileAttributes attrs) throws IOException {
Files.delete(file);
return FileVisitResult.CONTINUE;
} else {
throw e;
}
}

});
@Override
public FileVisitResult postVisitDirectory(Path dir,
IOException e) throws IOException {
if (e == null) {
Files.delete(dir);
return FileVisitResult.CONTINUE;
} else {
throw e;
}
}

});
} catch (NoSuchFileException e) {
// NoOp
}

}

if (outputDirectory != null && (!deps.libraries().isEmpty() || !extraPaths.isEmpty())) {
Expand Down

0 comments on commit 7a3586d

Please sign in to comment.