Reputation: 79
Does watchdog's "trigger event on file creation" depend on anything specific to how the files are created? I'm finding a discrepancy between when files are saved into a directory by an external program and when they are copied into the directory.
I'm using watchdog to monitor a directory, trigger off new files created in that directory, and then it runs a bunch of other scripts for those files. However I'm having a strange problem. I'm monitoring one directory where new files are saved into it by an external program over time. Watchdog does not trigger when these files appear in the directory. However I'm running a separate instance of the program which monitors a 2nd directory, and when I copy the files into this directory, watchdog triggers as expected and runs the code.
I'm running this on a Linux machine.
Any ideas?
Thanks.
Upvotes: 0
Views: 1716
Reputation: 629
Yes it does. Check how is the external program creating the file. In my case, the external program was creating a file with filename initiated with a '.' and ending with '.tmp' and when it is done writing to the temporary file it was moving it to actual filename which is ending with '.json'(for which I have set up the watcher). Only on_moved event is triggered in this case.
Overriding on_moved handler will solve the issue here.
Upvotes: 1