I download a snap shot of a camera that sometime does not succeed
This can be easily checked from filesize (ie: filesize very small = wrong file) and I wanted to use this to filter wrong files for further processing.
I tried to use the "watch" node, but I'm not sure why, sometimes it will not send the "msg.size"
I'm not certain of the issue but I do know that file system watches are not always going to do what you think because of the way that systems have different ways of updating files.
Really, you need some delays in a watch - rather like a debounce function when listening to physical switches - you can get some transient noise in a switch and some transient changes to a file.
The reason this happens is that the watch node triggers as soon as it sees the new file, which will often be before the file write has completed. In fact, as @TotallyInformation says, you may (usually will) get multiple events from the watch node for each file. The easiest solution is to use a Trigger node set to Send Nothing, then wait for a time then Send the Latest Message.
Well, I waited a few minutes to check, but it looks like I receive only one message (with missing size & type='none').
And the point is that I do not wish to wait for too long: my goal is to trigger a snapshot & send the valid ones "asap"
I think I may have found a workaround with node-red-contrib-fs : it can provide in a single msg all stats about files matching a defined pattern.