3
3
module Ext.Filewatch where
4
4
5
5
import Ext.Common
6
- import System.FSNotify
6
+ import qualified System.FSNotify as FSNotify
7
7
import Control.Concurrent (threadDelay )
8
8
import Control.Monad (forever )
9
9
import qualified Data.List as List
@@ -12,8 +12,10 @@ import qualified System.FilePath as FP
12
12
13
13
14
14
watch :: 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
17
19
trigger <-
18
20
Debounce. new
19
21
Debounce. Args
@@ -28,20 +30,20 @@ watch root action =
28
30
29
31
Ext.Common. debug $ " 👀 file watch booting for " ++ show root
30
32
-- start a watching job (in the background)
31
- _ <- watchTree
33
+ _ <- FSNotify. watchTree
32
34
mgr -- manager
33
35
root -- directory to watch
34
36
(const True ) -- predicate
35
37
(\ e -> do
36
38
let
37
39
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
45
47
46
48
-- @TODO it would be better to not listen to these folders in the `watchTree` when available
47
49
-- https://github.com/haskell-fswatch/hfsnotify/issues/101
0 commit comments