Browse Source

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 <luca.milanesio@gmail.com>
stable-4.7
Luca Milanesio 6 years ago
parent
commit
5a8ad44208
  1. 8
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java

8
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();
}

Loading…
Cancel
Save