From c2ab332e81caec773055da24c4a9d0ef58f04142 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Thu, 4 Jun 2020 13:51:17 +0900 Subject: [PATCH] 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 --- .../eclipse/jgit/internal/storage/file/ObjectDirectory.java | 4 ++-- 1 file 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 6a822d570..651cf1911 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); }