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) { if (data instanceof ReadableStream) {
const file = await open(path, options) const file = await open(path, options)
for await (const chunk of data) { const reader = data.getReader()
await file.write(chunk)
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 { } else {
await invoke('plugin:fs|write_file', data, { await invoke('plugin:fs|write_file', data, {
headers: { headers: {

Loading…
Cancel
Save