Skip to content

Commit

Permalink
Use createSyncAccessHandle for all browsers because it has been faste…
Browse files Browse the repository at this point in the history
…r in testing
  • Loading branch information
brandonpayton committed Sep 21, 2024
1 parent 092a895 commit 6169c26
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions packages/php-wasm/web/src/lib/directory-handle-mount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,12 @@ async function overwriteOpfsFile(
}

const opfsFile = await opfsParent.getFileHandle(name, { create: true });
const writer =
opfsFile.createWritable !== undefined
? // Google Chrome, Firefox, probably more browsers
await opfsFile.createWritable()
: // Safari
await opfsFile.createSyncAccessHandle();
const writer = await opfsFile.createSyncAccessHandle();
try {
await writer.truncate(0);
await writer.write(buffer);
writer.truncate(0);
writer.write(buffer);
} finally {
await writer.close();
writer.close();
}
}

Expand Down

0 comments on commit 6169c26

Please sign in to comment.