TotallyInformation / node-red-contrib-fs

Node-Red node template for host filing system handling
Apache License 2.0
15 stars 6 forks source link

Latest version (1.3.0/1) ignores 'start' parameter (solution in text) #19

Closed juggledad closed 4 years ago

juggledad commented 4 years ago

The latest version of fs-lister is ignoring the 'start' parameter when it is passed into the node. In the code at line 198 this: readdirp(path.join(node.start), options) should be changed to this: readdirp(path.join(clonedMsg.config.start), options)

Software and Package Versions

Software Version
Node.JS v12.13.0
npm 6.13.4
Node-RED v1.0.3
fs node 1.3.1
OS macOS
Browser Safari

How is Node-RED installed? Where is uibuilder installed?

No uibuilder NR installed per NR normally

juggledad commented 4 years ago

Here is a simple example of two flows. This is for running on a Pi. The idea is to look for the file "settings.js" in the /home/pi/.node-red' folder.

Screen Shot 2020-01-15 at 6 26 16 AM

CASE 1 has all the options in the fs file lister node

while

CASE 2 passs all the options in msg.payload.

[{"id":"c4660d28.b7e31","type":"inject","z":"9d6e4527.18bf3","name":"CASE 1 - options all in fs-lister","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":440,"wires":[["c7b8b65a.2a247"]]},{"id":"c7b8b65a.2a247","type":"fs-file-lister","z":"9d6e4527.18bf3","name":"","start":"/home/pi/.node-red","pattern":"settings.js","folders":"*","hidden":false,"lstype":"files","path":true,"single":true,"depth":"1","stat":false,"showWarnings":true,"x":500,"y":440,"wires":[["96e2367d.c84d98"]]},{"id":"96e2367d.c84d98","type":"debug","z":"9d6e4527.18bf3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":650,"y":440,"wires":[]},{"id":"23cec9a0.0a26d6","type":"inject","z":"9d6e4527.18bf3","name":"CASE 2 - options PASSED INTO fs-lister","topic":"","payload":"{\"start\":\"/home/pi/songs\",\"depth\":1,\"pattern\":\"settings.js\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":500,"wires":[["5a0b0d1d.e63064"]]},{"id":"5a0b0d1d.e63064","type":"fs-file-lister","z":"9d6e4527.18bf3","name":"","start":"/","pattern":"*.*","folders":"*","hidden":false,"lstype":"files","path":true,"single":true,"depth":"0","stat":false,"showWarnings":true,"x":500,"y":500,"wires":[["705fce68.f8c41"]]},{"id":"705fce68.f8c41","type":"debug","z":"9d6e4527.18bf3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":650,"y":500,"wires":[]}]

If you look at msg.config in the two debugs you will see hey are identical. The problem is in the code, it calls readdirp passing node.start which never gets updated with what's passed in from msg.payload. However clonedMsg.config.start is properly updated if the start is passed in msg.payload

TotallyInformation commented 4 years ago

Fixed in v1.3.2 now pushed. Will be published shortly.