haskell-fswatch / hfsnotify

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

When removing a file, Added event fired #69

Closed santios closed 6 years ago

santios commented 7 years ago

Hey guys, I'm playing with the library's default example and every time I remove a file, I got back an Added event, and sometimes, the expected Removed event. To undestand the problem better, I configured the manager with NoDebounce, and when removing a file, I get something like this:

Removed "/Users/santios/Documents/xxxx/hola.hs" 2017-07-04 21:23:16.182179 UTC
Added "/Users/santios/Documents/xxxx/hola.hs" 2017-07-04 21:23:16.182179 UTC

I'm not sure why the library is giving me back an Added event when removing a file. Any help is appreciated.

This is the code for reference and I'm on a Mac. OSX(10.12.3)

main :: IO ()
main = withManagerConf pollingConf $ \mgr -> do
  watchTree
    mgr
    "."
    (const True)
    print
  forever $ threadDelay 1000000

pollingConf :: WatchConfig
pollingConf = WatchConfig
      { confDebounce = NoDebounce
      , confPollInterval = 10^(6 :: Int) -- 1 second
      , confUsePolling = False
      }

Thanks!

tomv564 commented 7 years ago

Sorry for the late reply, but there is some previous discussion on OSX's FSEvents being unsuitable for file events in https://github.com/haskell-fswatch/hfsnotify/issues/36. The conclusion at that time was that an implementation using kqueue could help improve the behaviour.