From 0e947da72fa6b55b90922df740958b4244bb2fc3 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Wed, 26 Oct 2016 22:29:23 +0200 Subject: [PATCH] CleanFilter: use atomic move to move temporary file to media file Change-Id: I227a0ed6e4e15ac3d96f96a6cefcaf55680ad8bb Signed-off-by: Matthias Sohn --- .../src/org/eclipse/jgit/lfs/CleanFilter.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 c8a5918aa..fa5c74ccd 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);