]> source.dussan.org Git - jgit.git/commitdiff
GC: Avoid logging errors when deleting non-empty folders 54/128654/2
authorHector Caballero <hector.caballero@ericsson.com>
Tue, 4 Sep 2018 15:15:44 +0000 (11:15 -0400)
committerHector Caballero <hector.caballero@ericsson.com>
Wed, 5 Sep 2018 10:59:51 +0000 (06:59 -0400)
I88304d34c and Ia555bce00 modified the way errors are handled when
trying to delete non-empty reference folders. Before, this error was
silently ignored as it was considered an expected output. Now, every
failed folder delete is logged which can be noisy.

Ignore the DirectoryNotEmptyException but log any other error avoiding
deletion of an eligible folder.

Signed-off-by: Hector Oswaldo Caballero <hector.caballero@ericsson.com>
Change-Id: I194512f67885231d62c03976ae683e5cc450ec7c

org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java

index e4b0a46a304803c07bbc67abb01e8aab25bcc274..a4a2baa55b2502937cfe184fea32589835d4b513 100644 (file)
@@ -54,6 +54,7 @@ import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.nio.channels.Channels;
 import java.nio.channels.FileChannel;
+import java.nio.file.DirectoryNotEmptyException;
 import java.nio.file.DirectoryStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -909,6 +910,8 @@ public class GC {
        private void delete(Path d) {
                try {
                        Files.delete(d);
+               } catch (DirectoryNotEmptyException e) {
+                       // Don't log
                } catch (IOException e) {
                        LOG.error(MessageFormat.format(JGitText.get().cannotDeleteFile, d),
                                        e);