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

Unpacking application into custom folder #273

Closed
Mior opened this issue Dec 2, 2015 · 3 comments
Closed

Unpacking application into custom folder #273

Mior opened this issue Dec 2, 2015 · 3 comments

Comments

@Mior
Copy link

Mior commented Dec 2, 2015

We have created nw application which persist data in local sqlite database.

Problem when using nw-builder is that once user run's application it will create new temp directory. Every change is persisted to local db in this temp folder, but when user open application again different temp directory is created and changes from from db are lost. (in different unknown temp folder)

Is it possible to tell nw-builder when unpacking to use custom directory? Or at least same temp everytime?
Why is it using temp in first place? Couldn't it just unpack needed files in current dir?

Thanks for any info.

@theRaja
Copy link

theRaja commented Dec 4, 2015

Facing the same issue - is there any workaround?
Appreciate any help

@Mior
Copy link
Author

Mior commented Dec 4, 2015

@theRaja It seems its not issue of nw-builder but nw.js itself see nwjs/nw.js#815. When nw.js dealing with packed app.nw or even bundled together with nw.exe it is unpacking it into temp folder by default and I was not able to find any option to override this default behavior.

We were able to come up with 2 workarounds.

  1. embed your local db file along with nw.exe not inside of your app.nw nor bundled in nw.exe itself. Than you are able to point your code into that db file using executable location described here: How to get the location of nw.exe? nwjs/nw.js#1197 . This still create temp folder but your db is in different place so you don't lose persisted data.
    • One downside is that it take some time to start application as it always unpacking application into temp folder. (depending on size of your application).
  2. Pack you application in different manner as mentioned here Why nw unpack the exe file everytime when running it? nwjs/nw.js#815 . Meaning pack your application files along with nw's nw.exe (package.json need to be in same folder as nw.exe). nw.exe will just open package.json and thus your application as is in same folder every time.
    • Benefit same as before, db is always in same place. Also bootstrap of your application is really quick compare to 1. as it doesn't need to unpack your application into temp folder.
    • Downside is that all your code is visible right next to executable file.

Hope this helps and also if you come up with way how to overcome this nw.js default behavior, let me know.

@adam-lynch
Copy link
Contributor

I agree that this is not an issue with nw-builder.

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

3 participants