kolmodin/hinotify — pull request #7 by feuerbach (2013-12-01 22:34:22+00:00)
Title: addWatch: don't cancel other watches

Previously, addWatch would override any actions already registered with the
same watch descriptor (i.e. related to the same path). This commit changes the
behaviour so that the previously registered actions are kept.

Here's the test I used for this:

import Control.Concurrent
import Control.Exception
import Control.Applicative
import System.INotify

main = do
ino <- initINotify
let foo = "foo"
writeFile foo "blah"

_ <- addWatch ino [Open] foo $ \e -> putStrLn "opened"
evaluate =<< length <$> readFile foo
threadDelay (10^6)

_ <- addWatch ino [Access] foo $ \e -> putStrLn "accessed"
evaluate =<< length <$> readFile foo
threadDelay (10^6)

It's in a different style than the project's tests (it registers the actions rather than just gathering the events), so I didn't include it, but feel free to adapt it for the test suite.