Skip to content

Commit

Permalink
Fix file deletion bug
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnNiang committed Jun 17, 2019
1 parent 1d5bfc7 commit a2d4991
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/main/java/run/halo/app/utils/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,16 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
public static void deleteFolder(@NonNull Path deletingPath) throws IOException {
Assert.notNull(deletingPath, "Deleting path must not be null");

if (Files.notExists(deletingPath)) {
return;
}

log.info("Deleting [{}]", deletingPath);

// Delete folder recursively
org.eclipse.jgit.util.FileUtils.delete(deletingPath.toFile(),
org.eclipse.jgit.util.FileUtils.RECURSIVE | org.eclipse.jgit.util.FileUtils.RETRY);

// try (Stream<Path> pathStream = Files.walk(deletingPath)) {
// pathStream.sorted(Comparator.reverseOrder())
// .peek(path -> log.debug("Try to delete [{}]", path.toString()))
// .forEach(path -> {
// try {
// Files.delete(path);
// log.debug("Deleted [{}] successfully", path.toString());
// } catch (IOException e) {
// throw new ServiceException("Failed to delete " + path.toString(), e).setErrorData(deletingPath.toString());
// }
// });
// }

log.info("Deleted [{}] successfully", deletingPath);
}

Expand Down

0 comments on commit a2d4991

Please sign in to comment.