Просмотр исходного кода

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

Lucas Fernandes Nogueira 3 лет назад
Родитель
Сommit
ea43cf52db

+ 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 ?? []
   }

Некоторые файлы не были показаны из-за большого количества измененных файлов