Skip to content

Commit

Permalink
Convert writeFile to use buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
tillvit committed Dec 18, 2024
1 parent 477a83b commit 6ae8e00
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/src/util/file-handler/NodeFileHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,15 @@ export class NodeFileHandler implements BaseFileHandler {
}

private async writeHandle(handle: FileSystemFileHandle, data: Blob | string) {
let buf: ArrayBuffer
if (data instanceof Blob) {
buf = await data.arrayBuffer()
} else {
buf = new TextEncoder().encode(data).buffer
}
const writable = await handle.createWritable()
await writable.truncate(0)
await writable.write(data)
await writable.write(buf)
await writable.close()
}

Expand Down

0 comments on commit 6ae8e00

Please sign in to comment.