33module Ext.Filewatch where
44
55import Ext.Common
6- import System.FSNotify
6+ import qualified System.FSNotify as FSNotify
77import Control.Concurrent (threadDelay )
88import Control.Monad (forever )
99import qualified Data.List as List
@@ -12,8 +12,10 @@ import qualified System.FilePath as FP
1212
1313
1414watch :: FilePath -> ([FilePath ] -> IO () ) -> IO ()
15- watch root action =
16- trackedForkIO " Ext.Filewatch.watch" $ withManager $ \ mgr -> do
15+ watch root action = do
16+ let config = FSNotify. defaultConfig { FSNotify. confOnHandlerException = \ e -> Ext.Common. debug (" fsnotify: handler threw exception: " <> show e) }
17+
18+ trackedForkIO " Ext.Filewatch.watch" $ FSNotify. withManagerConf config $ \ mgr -> do
1719 trigger <-
1820 Debounce. new
1921 Debounce. Args
@@ -28,20 +30,20 @@ watch root action =
2830
2931 Ext.Common. debug $ " 👀 file watch booting for " ++ show root
3032 -- start a watching job (in the background)
31- _ <- watchTree
33+ _ <- FSNotify. watchTree
3234 mgr -- manager
3335 root -- directory to watch
3436 (const True ) -- predicate
3537 (\ e -> do
3638 let
3739 filepath = case e of
38- Added f _ _ -> f
39- Modified f _ _ -> f
40- ModifiedAttributes f _ _ -> f
41- Removed f _ _ -> f
42- WatchedDirectoryRemoved f _ _ -> f
43- CloseWrite f _ _ -> f
44- Unknown f _ _ _ -> f
40+ FSNotify. Added f _ _ -> f
41+ FSNotify. Modified f _ _ -> f
42+ FSNotify. ModifiedAttributes f _ _ -> f
43+ FSNotify. Removed f _ _ -> f
44+ FSNotify. WatchedDirectoryRemoved f _ _ -> f
45+ FSNotify. CloseWrite f _ _ -> f
46+ FSNotify. Unknown f _ _ _ -> f
4547
4648 -- @TODO it would be better to not listen to these folders in the `watchTree` when available
4749 -- https://github.com/haskell-fswatch/hfsnotify/issues/101
0 commit comments