mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-21 11:26:15 +02:00
fix(fs): convert async iterator syntax to manual read (#2550)
This commit is contained in:
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user