aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2012-02-21 14:34:42 -0500
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2012-02-21 14:34:42 -0500
commit0211d910017d1ba083b8c102a7a902ed103fe4f5 (patch)
tree586d6d288f2d66d17aef371ffadce9c2f5804e94 /org.eclipse.jgit
parent755dfdb40948f5c1ec79e06bde3b0a78c352f27f (diff)
parentb6d376a1775fd4efeb7742452c56e7629cbed885 (diff)
downloadjgit-0211d910017d1ba083b8c102a7a902ed103fe4f5.tar.gz
jgit-0211d910017d1ba083b8c102a7a902ed103fe4f5.zip
Merge "Add IGNORE_ERRORS to FileUtils.delete()"
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java
index 56d20d4ff0..0d97510c5c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java
@@ -78,6 +78,11 @@ public class FileUtils {
public static final int SKIP_MISSING = 4;
/**
+ * Option not to throw exceptions when a deletion finally doesn't succeed.
+ */
+ public static final int IGNORE_ERRORS = 8;
+
+ /**
* Delete file or empty folder
*
* @param f
@@ -106,7 +111,8 @@ public class FileUtils {
* if deletion of {@code f} fails. This may occur if {@code f}
* didn't exist when the method was called. This can therefore
* cause IOExceptions during race conditions when multiple
- * concurrent threads all try to delete the same file.
+ * concurrent threads all try to delete the same file. This
+ * exception is not thrown when IGNORE_ERRORS is set.
*/
public static void delete(final File f, int options) throws IOException {
if ((options & SKIP_MISSING) != 0 && !f.exists())
@@ -131,8 +137,9 @@ public class FileUtils {
return;
}
}
- throw new IOException(MessageFormat.format(
- JGitText.get().deleteFileFailed, f.getAbsolutePath()));
+ if ((options & IGNORE_ERRORS) == 0)
+ throw new IOException(MessageFormat.format(
+ JGitText.get().deleteFileFailed, f.getAbsolutePath()));
}
}