zen-fs / core

A filesystem, anywhere
https://zen-fs.github.io/core/
MIT License
104 stars 14 forks source link

`EPERM: File not opened with a readable mode` error #41

Closed Davilarek closed 5 months ago

Davilarek commented 5 months ago

Hello,

window.ZenFS.configure({
            backend: window.ZenFS_DOM.IndexedDB,
            storeName: "VirtualFS",
            idbFactory: indexedDB,
        }).then(() => {
            window.ZenFS.fs.writeFileSync("/test.txt", "hello world!");
        });

This code produces errors on dom 0.2.1 and core 0.7.8

Uncaught (in promise) Error: EPERM: File not opened with a readable mode.
    f ApiError.ts:139
    readSync file.ts:599
    createFileSync filesystem.ts:367
    le sync.ts:23
    Qt sync.ts:140
    rh sync.ts:239
    _r sync.ts:274
    run test.js:14
    promise callback*run test.js:13
    async* test.js:17
ApiError.ts:139:2

It seems that this.flag contains w flag in the read function.

james-pre commented 5 months ago

@Davilarek,

Thank you for submitting this issue! Just observing the stack trace, this is an issue with core not anything from dom, so I've transferred the issue.

Changing the default flag in the normalizeOptions call should fix this issue.

Does v0.7.11 fix your issue?

Davilarek commented 5 months ago

Looks like so, thanks

james-pre commented 5 months ago

@Davilarek,

Please let me know if you run into any other issues. Thanks again for submitting the issue.