Skip to content

Commit

Permalink
Fixes race condition when writing in bulk.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomilho committed Apr 16, 2024
1 parent dfe17c9 commit 6b90492
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/fileSystemAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,11 @@ class NativeFileAccessor implements FileAccessor {

writeBulk(ops: readonly FileWriteOp[]): Promise<void> {
return this.handle.borrow<void>(async fd => {
for (const { data, offset } of ops) {
fd.write(data, 0, data.byteLength, offset);
}
return Promise.all(
ops.map(({ data, offset }) => {
return fd.write(data, 0, data.byteLength, offset);
}),
);
});
}

Expand Down

0 comments on commit 6b90492

Please sign in to comment.