Belphemur / json-db-node-red

Node-RED Node to store easilly
GNU General Public License v3.0
5 stars 17 forks source link

Json File location not working correctly ? #1

Closed tdullers closed 8 years ago

tdullers commented 8 years ago

When I use the DataIn Node, it tries to save a new Json file and I always get access denied. My node-red instance is running with default settings so normally I would assume that all files are created in the node-red home directory. My node-red process runs with the 'pi' user which has full access rights on the node-red home directory.

The debug always gives me: DatabaseError: Can't save the database: Error: EACCES, permission denied 'JsonDB_TestCollection.json'

I did an strace on the node-red process and I get the impression it tries to create the file under the root filesystem '/':

stat64("JsonDB_TestCollection.json", 0x7ec310d8) = -1 ENOENT (No such file or directory) umask(0) = 022 umask(022) = 0 futex(0x7660046c, FUTEX_WAKE_PRIVATE, 1) = 1 mkdir("/", 0755) = -1 EEXIST (File exists) futex(0x7660046c, FUTEX_WAKE_PRIVATE, 1) = 1 cacheflush(0x3095eea0, 0x3095eed8, 0, 0x1, 0x7ec2aefc) = 0 stat64("/", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 gettimeofday({1460380969, 224554}, NULL) = 0 gettimeofday({1460380969, 224998}, NULL) = 0 gettimeofday({1460380969, 225426}, NULL) = 0 open("JsonDB_TestCollection.json", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = -1 EACCES (Permission denied)

Any advice would be more than welcome ! :)

Belphemur commented 8 years ago

I made a wrong assumption about where the file are stored.

Until I fix this issue, I advise you to set the Working directory of your Node-RED installation to be the user directory.

Belphemur commented 8 years ago

It's now corrected. The file will be put in the UserDirectory set in the Settings + JsonDB. By default: /home/$USER/.node-red/JsonDB