From 5a8ad44208c8b711077b9235839b66cd50803ede Mon Sep 17 00:00:00 2001 From: Luca Milanesio Date: Sun, 8 Jul 2018 23:41:00 +0100 Subject: [PATCH] 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 --- .../eclipse/jgit/internal/storage/file/RefDirectory.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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(); } -- 2.39.5