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 <thomas.wolf@paranor.ch>
(cherry picked from commit d9e767b431)
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
Thomas Wolf 2018-08-19 20:48:06 +02:00 committed by David Pursehouse
parent 6fe4505b2a
commit 94fad4412a
1 changed files with 5 additions and 0 deletions

View File

@ -63,6 +63,7 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.DirectoryNotEmptyException;
import java.nio.file.Files;
import java.security.DigestInputStream;
import java.security.MessageDigest;
@ -1093,6 +1094,10 @@ private static void delete(final File file, final int depth, LockFile rLck)
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;