haskell-fswatch / hfsnotify

Unified Haskell interface for basic file system notifications
BSD 3-Clause "New" or "Revised" License
136 stars 40 forks source link

Fire event variety "CloseWrite" #99

Closed docteurklein closed 3 years ago

docteurklein commented 3 years ago

I noticed that http://unisonweb.org 's UCM tool does not re-read my scratch file when entering it and then doing a save. I noticed a similar comment (although talking about WSL) https://github.com/haskell-fswatch/hfsnotify/issues/74#issuecomment-386076622 but I'm on linux and I would like this event to be observable, so that I could fix UCM downstream.

Any reason why this event is not listed in https://github.com/haskell-fswatch/hfsnotify/blob/master/src/System/FSNotify/Linux.hs#L84 ?

In any case, thanks for reading :)

EDIT: I use -e close_write instead of -e modify when writing inotifywait shell scripts and it usually works better; it basically subsumes modify behavior and does what you expect.

thomasjm commented 3 years ago

Any reason why this event is not listed

Not particularly--the main reason is that this library was written to be platform-independent, so events need to ultimately get mapped to the platform-independent Event type in System.FSNotify.Types. So events that don't have direct equivalents on all platforms weren't added historically.

However, I don't think we actually need an event to be supported on all platforms in order for it to be useful. For example, I recently added the ModifiedAttributes event on master branch. We could do the same thing to add a new CloseWrite event that only gets fired on Linux.

Would you like to make a PR?

thomasjm commented 3 years ago

FYI I just pushed support for this in e4ba64c3bc1084ba7efeffde95582ec416bc5c66

docteurklein commented 3 years ago

thanks a lot :)