Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package org.eclipse.core.internal.localstore;

import java.io.*;
import java.nio.file.AtomicMoveNotSupportedException;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;

Expand Down Expand Up @@ -82,8 +83,13 @@ protected void commit() throws IOException {
if (!temp.exists()) {
return;
}
Files.copy(temp.toPath(), target.toPath(), StandardCopyOption.REPLACE_EXISTING);
temp.delete();
try {
// a rename does not rewrite the bytes and never leaves a partially written target
Files.move(temp.toPath(), target.toPath(), StandardCopyOption.ATOMIC_MOVE);
Comment thread
iloveeclipse marked this conversation as resolved.
} catch (AtomicMoveNotSupportedException e) {
Files.copy(temp.toPath(), target.toPath(), StandardCopyOption.REPLACE_EXISTING);
temp.delete();
}
}

protected void createTempFile(String tempPath) {
Expand Down
Loading