Does the DirectoryWatcher stuff in lucee work?
# lucee
m
Does the DirectoryWatcher stuff in lucee work?
I tried implementing it with: // in my application.cfc this.directoryWatchers = [{ directory: "C:\\FTP\\Upload", listener: "DirectoryWatcherListener", interval: 60 // Check every 60 seconds }]; // DirectoryWatcherListener.cfc component { public void function onAdd(required string path) { // Handle a file being added application.svc.email.send(mail={to = "me@mydomain.com", subject="new file", body = "new file #arguments.path#"}); } public void function onModify(required string path) { // Handle a file being modified } }
b
@mrtom I'm familiar a little with Lucee's event gateway directory watcher, but I've never heard of
this.directoryWatchers
in the
Application.cfc
nor can I find any info on Google. Is this a new feature?
m
I'm embarassed to say <g> I asked chatgpt for best practice of watching a directory in lucee, and it had exact instructions lol
b
I do a bit of directory-watching, but I use the CommandBox CLi to do some inside of task runners, which works quite well. I can run them as a service. https://commandbox.ortusbooks.com/task-runners/watchers
I'm pretty sure ChatGPT just made that up, lol
It makes up a LOT of crap and then pretends it's actually true 🙂
m
I think so - damnit! It had a really nice soltuion
q
I'm fairly sure DirectoryWatcher is a ACF specific eventgateway that was used as a demo.
b
Lucee has a directory watcher event gateway as well.
q
Ah, looks like it still is there. I thought that was one of the things that got pulled /way/ back.