Skip to content

Is there a way to implement InMemory DB that places whole files into single buffer? #379

@vitonsky

Description

@vitonsky

I need some emscripten FS that would make able to dump content and load content fast, but all operations must happens in RAM, because all data are secret data encrypted on high level.

Ideally it must be a virtual FS that places whole data in single buffer, like tar archive or something.

Is it possible with BrowserFS? Maybe this project have solution for that, or you may navigate me to another solution, or explain how to implement this code myself with BrowserFS?

Ideally the API would looks kinda

// Initializing
const fs = new CustomFS();

// First time we set an empty buffer or maybe create formatted buffer with some util
const content = new Uint8Array().buffer;
fs.setBuffer(content);

// Now custom FS acts with files from our buffer. Read, write, etc.
// We may dump buffer immediately, to snapshot our FS,
// and then load buffer next run, to continue from snapshot state
dumpData(content);

I work on note-taking app that uses PGlite that uses emscripten FS. Users may encrypt their workspace, this is core feature, so i can't just mount NodeFS, since secret data would be placed naked on user disk and may be recovered later. I have issue in PGlite repo with more details if you need a context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions