From d9e767b431eae7978613cc8e0ade7467ec04376c Mon Sep 17 00:00:00 2001 From: Thomas Wolf Date: Sun, 19 Aug 2018 20:48:06 +0200 Subject: [PATCH] Suppress warning for trying to delete non-empty directory This is actually a fairly common occurrence; deleting the parent directories can work only if the file deleted was the last one in the directory. Bug: 537872 Change-Id: I86d1d45e1e2631332025ff24af8dfd46c9725711 Signed-off-by: Thomas Wolf --- .../org/eclipse/jgit/internal/storage/file/RefDirectory.java | 5 +++++ 1 file changed, 5 insertions(+) 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 a3e9437d95..d3d01aac60 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 @@ -65,6 +65,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.io.InterruptedIOException; +import java.nio.file.DirectoryNotEmptyException; import java.nio.file.Files; import java.security.DigestInputStream; import java.security.MessageDigest; @@ -1275,6 +1276,10 @@ public class RefDirectory extends RefDatabase { for (int i = 0; i < depth; ++i) { try { Files.delete(dir.toPath()); + } catch (DirectoryNotEmptyException e) { + // Don't log; normal case when there are other refs with the + // same prefix + break; } catch (IOException e) { LOG.warn("Unable to remove path {}", dir, e); break; -- 2.39.5