Closed james-pre closed 6 months ago
does v0.9.4
fix need any additional changes?
window.ZenFS.configure({
backend: window.ZenFS_DOM.IndexedDB,
storeName: "VirtualFS",
idbFactory: indexedDB,
}).then(() => {
if (!window.ZenFS.fs.existsSync("/test.txt")) {
console.log("creating because missing");
window.ZenFS.fs.writeFileSync("/test.txt", "hello world!");
window.ZenFS.fs.mkdirSync("/test123");
window.ZenFS.fs.mkdirSync("/test123/test456");
window.ZenFS.fs.writeFileSync("/test123/test456/test.txt", "hello world!");
}
else {
console.log("found");
}
console.log(window.ZenFS.fs.readFileSync("/test123/test456/test.txt")); // on first: works, on second: empty
window.ZenFS.fs.readFile("/test123/test456/test.txt", "utf8", console.log); // always works!
});
this example here still looks to have the issue
I have some different results.
On the first run:
Error: ENOENT: No such file or directory, '/test123/test456/test.txt'
On the second run:After some investigation, I've found that when opening a file from the sync file system, the resulting file's buffer is empty.
This is definitely confusing behavior. I'm looking into it and will hopefully correct the issue soon.
The reason the error is occurring on the first run is due to the queued operations not being completed when readFile
is called. This should be fixed in 9aca101.
The second issue is caused by crossCopy
calling File.writeSync
without passing in length, so it defaulted to File.stats.size
, which was 0 because it was a newly created file. This should be fixed by 560b307.
@Davilarek Fixes have been released in v0.9.5. Please let me know if this fixes the issues on your side.
Thanks, it looks like this issue is solved.
This issue was first mentioned on Discord:
@Davilarek:
Me:
@Davilarek:
Me:
@Davilarek:
In my investigation, I found that:
Async.crossCopy
correctlyawait
s itselfAsyncStoreFS.ready
correctlyawait
ssuper.ready
Async.ready
correctlyawait
s the sync FSAsync.ready
does notawait
super.ready
!Async.ready
:However, since
FileSystem
can be passed toAsync
care must be taken to ensure thatsuper.ready
exists.