fix(fs): convert async iterator syntax to manual read (#2550)

pull/2561/head
Tim Ramage 3 months ago committed by GitHub
parent a9cbefc910
commit 831c35ff39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,6 @@
---
"fs": "patch:bug"
"fs-js": "patch:bug"
---
Fix `writeFile` ReadableStream handling due to missing async iterator support on macOS platform

File diff suppressed because one or more lines are too long

@ -1075,10 +1075,18 @@ async function writeFile(
if (data instanceof ReadableStream) {
const file = await open(path, options)
for await (const chunk of data) {
await file.write(chunk)
const reader = data.getReader()
try {
while (true) {
const { done, value } = await reader.read()
if (done) break
await file.write(value)
}
} finally {
reader.releaseLock()
await file.close()
}
await file.close()
} else {
await invoke('plugin:fs|write_file', data, {
headers: {

Loading…
Cancel
Save