Browse Source

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>
stable-5.7
David Pursehouse 5 years ago
parent
commit
c2ab332e81
  1. 4
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java

4
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);
}

Loading…
Cancel
Save