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

Change-Id: I227a0ed6e4e15ac3d96f96a6cefcaf55680ad8bb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
Matthias Sohn 2016-10-26 22:29:23 +02:00
parent 999106bb84
commit 0e947da72f
1 changed files with 3 additions and 1 deletions

View File

@ -47,6 +47,7 @@
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 int run() throws IOException {
}
} 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);