rjeczalik / notify

File system event notification library on steroids.
MIT License
902 stars 128 forks source link

Events in MacOS #157

Closed Shashi-S closed 6 years ago

Shashi-S commented 6 years ago

Hi, I'm not familiar with file system event on MacOS. I'm using notify recursive watcher to understand the events generated when file/folder related operation is done under the folder being watched. I noticed that "rename" event is seen when a file is removed (move to trash) and also when the content of the file is modified. I understand its happening because of using notify.All option.

Can you please suggest me the notify option that might be used specific to MacOS? So that I can distinguish between whether the rename event is actually due to renaming of the file not resulted from removing the file.

I learnt from one of the issue reported under this project that for Windows we can set notify.FileNotifyChangeFileName, notify.FileNotifyChangeDirName to get more events specific to Windows and then aggregate the events. Is there something equivalent to this when working for MacOS? Tried with FSEventsRemoved,FSEventsModified but didn't help

Thanks for your help.

rjeczalik commented 6 years ago

I noticed that "rename" event is seen when a file is removed (move to trash) and also when the content of the file is modified.

Unfortunately there's nothing notify can provide for you to detect that behaviour out of the box. If a delete operation from some UI results in a move operation on the filesystem - notify is going to report a move operation, not the intention behind it. Figuring it out is up to the user. The same applies to e.g. file modification in majority of the IDE - they write to a temporary file then replace the original with it - notify will only report the underlying filesystem events.

We were thinking in the past about another utility package, that builds on top of notify and provides such features as described here or the one you're asking for. Unfortunately we're short on time and can't pursue that goal ourselves - if you'd want to tackle it, I can give a few pointers.

I'm closing this issue for now.