mirror of https://github.com/halo-dev/halo
Fix file deletion bug
parent
1d5bfc79c7
commit
a2d4991e42
|
@ -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<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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue