Skip to content

Commit

Permalink
fix: 0 byte file read write working in tauri
Browse files Browse the repository at this point in the history
  • Loading branch information
abose committed Dec 7, 2023
1 parent 3f53baf commit ba0efb2
Show file tree
Hide file tree
Showing 12 changed files with 956 additions and 612 deletions.
1 change: 1 addition & 0 deletions dist/phoenix-fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ function _writeBinaryFile(ws, metadata, dataBuffer) {
const fullPath = metadata.data.path,
mode = metadata.data.mode,
flag = metadata.data.flag;
dataBuffer = dataBuffer || new ArrayBuffer(0);
fs.writeFile(fullPath, Buffer.from(dataBuffer), {mode, flag})
.then( ()=> {
_sendResponse(ws, metadata);
Expand Down
6 changes: 4 additions & 2 deletions dist/virtualfs-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -19058,14 +19058,16 @@ function $d1f4f8cce920e9b9$var$rename(oldPath, newPath, callback) {
options = $d1f4f8cce920e9b9$require$Utils.validateFileOptions(options, $d1f4f8cce920e9b9$require$Constants.BINARY_ENCODING, "r");
if (!globalObject.__TAURI__ || $d1f4f8cce920e9b9$var$forceNodeWs || $d1f4f8cce920e9b9$var$preferNodeWs && $d1f4f8cce920e9b9$require$NodeTauriFS.isNodeWSReady()) {
$d1f4f8cce920e9b9$require$NodeTauriFS.readBinaryFile(path).then((contents)=>{
// contents is Array buffer
// contents is Array buffer, can be undefined if empty file
contents = contents || new ArrayBuffer(0);
$d1f4f8cce920e9b9$var$_processContents(contents, options.encoding, callback, path);
}).catch(callback);
return;
}
const platformPath = $d1f4f8cce920e9b9$require$Utils.getTauriPlatformPath(path);
__TAURI__.fs.readBinaryFile(platformPath).then((contents)=>{
// contents is Uint8Array
// contents is Array buffer, can be undefined if empty file
contents = contents || new ArrayBuffer(0);
$d1f4f8cce920e9b9$var$_processContents(contents, options.encoding, callback, path);
}).catch((err)=>{
callback($d1f4f8cce920e9b9$var$mapOSTauriErrorMessage(err, path, `Failed to read File at path ${path}`));
Expand Down
2 changes: 1 addition & 1 deletion dist/virtualfs-debug.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/virtualfs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/virtualfs.js.map

Large diffs are not rendered by default.

178 changes: 89 additions & 89 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@phcode/fs",
"description": "Phoenix virtual file system over filer/ browser fs access/ tauri / phoenix web socket APIs",
"version": "2.0.5",
"version": "2.0.6",
"keywords": [
"phoenix",
"browser",
Expand Down Expand Up @@ -45,7 +45,7 @@
"dist/phoenix-fs.js"
],
"devDependencies": {
"@tauri-apps/cli": "1.4.0",
"@tauri-apps/cli": "1.5.7",
"anymatch": "^3.1.3",
"browser-mime": "1.0.1",
"buffer": "^6.0.3",
Expand Down
Loading

0 comments on commit ba0efb2

Please sign in to comment.