Skip to content

Commit

Permalink
Use a writable handle for syncing the destination handle
Browse files Browse the repository at this point in the history
man fsync(2):
On some UNIX systems (but not Linux), fd must be a writable file descriptor.
  • Loading branch information
GarboMuffin committed Sep 28, 2023
1 parent 3db0df2 commit b7939d5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src-main/atomic-write-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ const createAtomicWriteStream = async (path) => {
// - We still avoid keeping the entire file in memory at once
await copy(tempPath, path);

const destinationHandle = await fsPromises.open(path, 'r');
// Per man fsync(2):
// On some UNIX systems (but not Linux), fd must be a writable file descriptor.
const destinationHandle = await fsPromises.open(path, 'ax');
await destinationHandle.sync();
await destinationHandle.close();

Expand Down

0 comments on commit b7939d5

Please sign in to comment.