Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

persistent file storage with NODEFS #92

Open
julien33 opened this issue Mar 6, 2015 · 6 comments
Open

persistent file storage with NODEFS #92

julien33 opened this issue Mar 6, 2015 · 6 comments

Comments

@julien33
Copy link

julien33 commented Mar 6, 2015

To allow persistent file storage with NODEFS, and real time update of a SQLITE file instead of loading the whole thing at startup and writing it down using export, I had to changed the class constructor, the close function and debug an issue related to emscriten :

api.coffee : temporary random filename replaced by NODEFS mount relative filename

    constructor: (data) ->
        @filename = '/extfs/'+data
        FS.mkdir '/extfs'
        FS.mount NODEFS, {root:'.'}, '/extfs'
        @handleError sqlite3_open @filename, apiTemp
        @db = getValue(apiTemp, 'i32')
        @statements = {} # A list of all prepared statements of the database

    'close': ->
        stmt['free']() for _,stmt of @statements
        @handleError sqlite3_close_v2 @db
        @db = null

Makefile: modified to ensure closure don't break NODEFS

    optimized: EMFLAGS= --memory-init-file 0 --closure 0 -O3 -s INLINING_LIMIT=50

emscripten / src / library_nodefs.js : modified to avoid file "DeleteOnClose" bug under windows

    stream.nfd = fs.openSync(path, NODEFS.flagsToPermissionString(stream.flags & 0xFFFF));
    // instead of :
    // stream.nfd = fs.openSync(path, NODEFS.flagsToPermissionString(stream.flags));

Perhaps the constructor could take an optional argument to specify witch file system to use (MEMFS / NODEFS / IDBFS / ...

@ndarilek
Copy link

Any reason this issue has languished? This description makes it look like an easy fix to add the filesystem type to the constructor, and maybe a few branch points at critical locations. So I'm wondering if there's hidden complexity that I'm not aware of.

I'm fairly new to Emscripten. Was hoping to leverage Spatiasql in a locally-running PWA, hosting databases several GB in size. The users of this app would know that they'd likely be working with large data, so that isn't the issue, but memory use is. I'd wanted to use the browser, its UI, and its geospatial/other capabilities as a cross-platform runtime, in situations where the user may not have a solid internet connection. For the moment I'll investigate something else, but the trend really does seem to be toward the web in some form or another.

Thanks.

@lovasoa
Copy link
Member

lovasoa commented Jan 21, 2018

A pull request is always welcome!

@ndarilek
Copy link

ndarilek commented Jan 21, 2018 via email

@dinedal
Copy link
Collaborator

dinedal commented Jan 22, 2018

@ndarilek I believe the largest obstacle to this issue remains the same as many of the features or improvements we'd love to make, it's less about it being possible and more about the time required.

That said, there's nothing that would prevent this project from using NODEFS, Emscripten or not. It would just take time and effort to get it integrated.

@ndarilek
Copy link

ndarilek commented Jan 22, 2018 via email

@dinedal
Copy link
Collaborator

dinedal commented Jan 22, 2018

Yes, that sounds entirely accurate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants