summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2020-06-04 13:51:17 +0900
committerDavid Pursehouse <david.pursehouse@gmail.com>2020-06-04 14:06:21 +0900
commitc2ab332e81caec773055da24c4a9d0ef58f04142 (patch)
treef14ffaed1f3296cd18a62b508e68e7abd4b92806
parente624e1310836747c15afeb411d9fd7eaee41ddae (diff)
downloadjgit-c2ab332e81caec773055da24c4a9d0ef58f04142.tar.gz
jgit-c2ab332e81caec773055da24c4a9d0ef58f04142.zip
ObjectDirectory: Fail immediately when atomic move is not supported
If atomic move is not supported, AtomicMoveNotSupportedException will be thrown on the first attempt to move the temp file. There is no point attempting the move operation a second time because it will only fail for the same reason. Add an immediate return of FAILURE on the first occasion. Remove the unnecessary handling of the exception in the second block. Change-Id: I4658a8b37cfec2d7ef0217c8346e512968d0964c Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java4
1 files changed, 2 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java
index 6a822d570a..651cf1911e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java
@@ -693,6 +693,8 @@ public class ObjectDirectory extends FileObjectDatabase {
return InsertLooseObjectResult.INSERTED;
} catch (AtomicMoveNotSupportedException e) {
LOG.error(e.getMessage(), e);
+ FileUtils.delete(tmp, FileUtils.RETRY);
+ return InsertLooseObjectResult.FAILURE;
} catch (IOException e) {
// ignore
}
@@ -708,8 +710,6 @@ public class ObjectDirectory extends FileObjectDatabase {
dst.setReadOnly();
unpackedObjectCache.add(id);
return InsertLooseObjectResult.INSERTED;
- } catch (AtomicMoveNotSupportedException e) {
- LOG.error(e.getMessage(), e);
} catch (IOException e) {
LOG.debug(e.getMessage(), e);
}