From: Luca Milanesio Date: Sun, 8 Jul 2018 22:41:00 +0000 (+0100) Subject: Do not ignore path deletion errors X-Git-Tag: v4.7.2.201807261330-r~4 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5a8ad44208c8b711077b9235839b66cd50803ede;p=jgit.git Do not ignore path deletion errors Log as warning when an attempt to remove a directory fails. This helps troubleshooting some bugs like the GC leaving behind empty directories. Change-Id: Idb94ce17f8be9668a970c7ecae31436bf434073c Signed-off-by: Luca Milanesio --- diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java index 51701f6dd3..48fdf8119f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java @@ -63,6 +63,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; +import java.nio.file.Files; import java.security.DigestInputStream; import java.security.MessageDigest; import java.text.MessageFormat; @@ -1090,8 +1091,11 @@ public class RefDirectory extends RefDatabase { } File dir = file.getParentFile(); for (int i = 0; i < depth; ++i) { - if (!dir.delete()) { - break; // ignore problem here + try { + Files.delete(dir.toPath()); + } catch (IOException e) { + LOG.warn("Unable to remove path {}", dir, e); + break; } dir = dir.getParentFile(); }