Fix file deletion bug

pull/210/head
johnniang 2019-06-17 21:12:44 +08:00
parent 1d5bfc79c7
commit a2d4991e42
1 changed files with 4 additions and 13 deletions

View File

@ -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);
}