Convert async iterator syntax to manual read

pull/2550/head
Tim Ramage 4 months ago
parent 38deef43dc
commit e4a34c9e6d

@ -1075,9 +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, {

Loading…
Cancel
Save