Эх сурвалжийг харах

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

Lucas Fernandes Nogueira 3 жил өмнө
parent
commit
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 ?? []
   }

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно