Browse Source

CleanFilter: use atomic move to move temporary file to media file

Change-Id: I227a0ed6e4e15ac3d96f96a6cefcaf55680ad8bb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-4.6
Matthias Sohn 8 years ago
parent
commit
0e947da72f
  1. 4
      org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/CleanFilter.java

4
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.io.OutputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption; import java.nio.file.StandardOpenOption;
import java.security.DigestOutputStream; import java.security.DigestOutputStream;
@ -162,7 +163,8 @@ public class CleanFilter extends FilterCommand {
} }
} else { } else {
FileUtils.mkdirs(mediaFile.getParent().toFile(), true); 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 lfsPointer = new LfsPointer(loid, size);
lfsPointer.encode(out); lfsPointer.encode(out);

Loading…
Cancel
Save