Browse Source

GC: Avoid logging errors when deleting non-empty folders

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
stable-4.7
Hector Caballero 6 years ago
parent
commit
b7351facd5
  1. 3
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java

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

@ -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);

Loading…
Cancel
Save