Skip to content

Commit ba0efb2

Browse files
committed
fix: 0 byte file read write working in tauri
1 parent 3f53baf commit ba0efb2

File tree

12 files changed

+956
-612
lines changed

12 files changed

+956
-612
lines changed

dist/phoenix-fs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ function _writeBinaryFile(ws, metadata, dataBuffer) {
279279
const fullPath = metadata.data.path,
280280
mode = metadata.data.mode,
281281
flag = metadata.data.flag;
282+
dataBuffer = dataBuffer || new ArrayBuffer(0);
282283
fs.writeFile(fullPath, Buffer.from(dataBuffer), {mode, flag})
283284
.then( ()=> {
284285
_sendResponse(ws, metadata);

dist/virtualfs-debug.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19058,14 +19058,16 @@ function $d1f4f8cce920e9b9$var$rename(oldPath, newPath, callback) {
1905819058
options = $d1f4f8cce920e9b9$require$Utils.validateFileOptions(options, $d1f4f8cce920e9b9$require$Constants.BINARY_ENCODING, "r");
1905919059
if (!globalObject.__TAURI__ || $d1f4f8cce920e9b9$var$forceNodeWs || $d1f4f8cce920e9b9$var$preferNodeWs && $d1f4f8cce920e9b9$require$NodeTauriFS.isNodeWSReady()) {
1906019060
$d1f4f8cce920e9b9$require$NodeTauriFS.readBinaryFile(path).then((contents)=>{
19061-
// contents is Array buffer
19061+
// contents is Array buffer, can be undefined if empty file
19062+
contents = contents || new ArrayBuffer(0);
1906219063
$d1f4f8cce920e9b9$var$_processContents(contents, options.encoding, callback, path);
1906319064
}).catch(callback);
1906419065
return;
1906519066
}
1906619067
const platformPath = $d1f4f8cce920e9b9$require$Utils.getTauriPlatformPath(path);
1906719068
__TAURI__.fs.readBinaryFile(platformPath).then((contents)=>{
19068-
// contents is Uint8Array
19069+
// contents is Array buffer, can be undefined if empty file
19070+
contents = contents || new ArrayBuffer(0);
1906919071
$d1f4f8cce920e9b9$var$_processContents(contents, options.encoding, callback, path);
1907019072
}).catch((err)=>{
1907119073
callback($d1f4f8cce920e9b9$var$mapOSTauriErrorMessage(err, path, `Failed to read File at path ${path}`));

dist/virtualfs-debug.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/virtualfs.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/virtualfs.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 89 additions & 89 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@phcode/fs",
33
"description": "Phoenix virtual file system over filer/ browser fs access/ tauri / phoenix web socket APIs",
4-
"version": "2.0.5",
4+
"version": "2.0.6",
55
"keywords": [
66
"phoenix",
77
"browser",
@@ -45,7 +45,7 @@
4545
"dist/phoenix-fs.js"
4646
],
4747
"devDependencies": {
48-
"@tauri-apps/cli": "1.4.0",
48+
"@tauri-apps/cli": "1.5.7",
4949
"anymatch": "^3.1.3",
5050
"browser-mime": "1.0.1",
5151
"buffer": "^6.0.3",

0 commit comments

Comments
 (0)