diff --git a/src/main/java/run/halo/app/utils/FileUtils.java b/src/main/java/run/halo/app/utils/FileUtils.java index b03d29452..ce8512c39 100644 --- a/src/main/java/run/halo/app/utils/FileUtils.java +++ b/src/main/java/run/halo/app/utils/FileUtils.java @@ -66,25 +66,16 @@ public class FileUtils { 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 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); }