diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2016-10-26 22:29:23 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2016-10-26 23:15:08 +0200 |
commit | 0e947da72fa6b55b90922df740958b4244bb2fc3 (patch) | |
tree | 92a40effcfc17e828238079b76fbd41c49c04066 | |
parent | 999106bb848bafc47d956aba933fac7cda636257 (diff) | |
download | jgit-0e947da72fa6b55b90922df740958b4244bb2fc3.tar.gz jgit-0e947da72fa6b55b90922df740958b4244bb2fc3.zip |
CleanFilter: use atomic move to move temporary file to media file
Change-Id: I227a0ed6e4e15ac3d96f96a6cefcaf55680ad8bb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r-- | org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/CleanFilter.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/CleanFilter.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/CleanFilter.java index c8a5918aa7..fa5c74ccd9 100644 --- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/CleanFilter.java +++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/CleanFilter.java @@ -47,6 +47,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.StandardCopyOption; import java.nio.file.StandardOpenOption; import java.security.DigestOutputStream; @@ -162,7 +163,8 @@ public class CleanFilter extends FilterCommand { } } else { FileUtils.mkdirs(mediaFile.getParent().toFile(), true); - FileUtils.rename(tmpFile.toFile(), mediaFile.toFile()); + FileUtils.rename(tmpFile.toFile(), mediaFile.toFile(), + StandardCopyOption.ATOMIC_MOVE); } LfsPointer lfsPointer = new LfsPointer(loid, size); lfsPointer.encode(out); |