]> source.dussan.org Git - jgit.git/commitdiff
Do not ignore path deletion errors 67/125767/1
authorLuca Milanesio <luca.milanesio@gmail.com>
Sun, 8 Jul 2018 22:41:00 +0000 (23:41 +0100)
committerLuca Milanesio <luca.milanesio@gmail.com>
Sun, 8 Jul 2018 22:44:17 +0000 (23:44 +0100)
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 <luca.milanesio@gmail.com>
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java

index 51701f6dd3f0e6108866319dc1826ccc3e48e8d6..48fdf8119f5a530b4662a473b3db25b956d1bf48 100644 (file)
@@ -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();
                }