浏览代码

fix(api): `writeBinaryFile` sends an empty contents with only one arg (#4368)

Lucas Fernandes Nogueira 3 年之前
父节点
当前提交
ea43cf52db
共有 4 个文件被更改,包括 7 次插入2 次删除
  1. 5 0
      .changes/fix-write-binary-file-api.md
  2. 0 0
      core/tauri/scripts/bundle.js
  3. 0 0
      examples/api/dist/assets/vendor.js
  4. 2 2
      tooling/api/src/fs.ts

+ 5 - 0
.changes/fix-write-binary-file-api.md

@@ -0,0 +1,5 @@
+---
+"api": patch
+---
+
+Fixes the `writeBinaryFile` sending an empty file contents when only the first argument is passed.

文件差异内容过多而无法显示
+ 0 - 0
core/tauri/scripts/bundle.js


文件差异内容过多而无法显示
+ 0 - 0
examples/api/dist/assets/vendor.js


+ 2 - 2
tooling/api/src/fs.ts

@@ -290,7 +290,7 @@ async function writeBinaryFile(
 
 /**
  * Writes a byte array content to a file.
- * @example Write a binary file to the `$APPEDIR/avatar.png` path
+ * @example Write a binary file to the `$APPDIR/avatar.png` path
  * ```typescript
  * import { writeBinaryFile, BaseDirectory } from '@tauri-apps/api/fs';
  * await writeBinaryFile({ path: 'avatar.png', contents: new Uint8Array([]) }, { dir: BaseDirectory.App });
@@ -336,7 +336,7 @@ async function writeBinaryFile(
 
   if (contents && 'dir' in contents) {
     fileOptions = contents
-  } else {
+  } else if (typeof path === 'string') {
     // @ts-expect-error
     file.contents = contents ?? []
   }

部分文件因为文件数量过多而无法显示