0
votes

I am building a desktop app with node-webkit. I have used the nw-builder to build for windows 32 & windows 64 bit from my mac. The program is working fine in windows except that the files I use to store data is gone upon program exit.

The app is packed as a .pak file and I am assuming when the program is closed , all the files along with are erased. So when I start the app again , the persisted data is gone.

How can I persist data in Windows for node-webkit ?

I am using 'node-persist' package for my persistence. In Mac its creating a folder called 'persist' inside the .app file and writing files to that which works fine.

But in windows , due to the .pak file , the persisted files are lost when the program is closed. How do I fix this ? Is there a way to to store files outside the .pak. The .pak seems to be extracted to a temp location.

UPDATE ( solved )

I have used App.dataPath as described in https://github.com/nwjs/nw.js/wiki/App

excerpt :

Get the application's data path in user's directory. Windows: %LOCALAPPDATA%/; Linux: ~/.config/; OSX: ~/Library/Application Support/ where is the field in the manifest.

PopcornTime also uses the same in its database.js file. https://git.popcorntime.io/popcorntime/desktop/blob/master/src/app/database.js

1

1 Answers

1
votes

You have multiple options:

https://github.com/nwjs/nw.js/wiki/Save-persistent-data-in-app

Personally, I used localStorage. For simple needs, it's very easy and mimics browser behaviour.