Skip to content

Commit 6e6b1f4

Browse files
committed
Fix fsnotify API changes
1 parent 9e4bb74 commit 6e6b1f4

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

ext-sentry/Ext/Filewatch.hs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ module Ext.Filewatch where
44

55
import Ext.Common
66
import System.FSNotify
7-
import Control.Concurrent (threadDelay, forkIO)
7+
import Control.Concurrent (threadDelay)
88
import Control.Monad (forever)
99
import qualified Data.List as List
1010
import qualified Control.FoldDebounce as Debounce
11-
import qualified System.Directory as Dir
1211
import qualified System.FilePath as FP
1312

13+
14+
watch :: FilePath -> ([FilePath] -> IO ()) -> IO ()
1415
watch root action =
1516
trackedForkIO "Ext.Filewatch.watch" $ withManager $ \mgr -> do
1617
trigger <-
@@ -26,32 +27,37 @@ watch root action =
2627
}
2728

2829
-- start a watching job (in the background)
29-
watchTree
30+
_ <- watchTree
3031
mgr -- manager
3132
root -- directory to watch
3233
(const True) -- predicate
3334
(\e -> do
3435
let
35-
f = case e of
36-
Added f _ _ -> f
37-
Modified f _ _ -> f
38-
Removed f _ _ -> f
39-
Unknown f _ _ _ -> f
36+
filepath = case e of
37+
Added f _ _ -> f
38+
Modified f _ _ -> f
39+
ModifiedAttributes f _ _ -> f
40+
Removed f _ _ -> f
41+
WatchedDirectoryRemoved f _ _ -> f
42+
CloseWrite f _ _ -> f
43+
Unknown f _ _ _ -> f
4044

4145
-- @TODO it would be better to not listen to these folders in the `watchTree` when available
4246
-- https://github.com/haskell-fswatch/hfsnotify/issues/101
4347
shouldRefresh = do
44-
not (List.isInfixOf ".git" f)
45-
&& not (List.isInfixOf "elm-stuff" f)
46-
&& not (List.isInfixOf "node_modules" f)
47-
&& not (List.isInfixOf "data" f)
48-
&& not (List.isInfixOf "elm-pkg-js-includes.min.js" f)
48+
not (List.isInfixOf ".git" filepath)
49+
&& not (List.isInfixOf "elm-stuff" filepath)
50+
&& not (List.isInfixOf "node_modules" filepath)
51+
&& not (List.isInfixOf "data" filepath)
52+
&& not (List.isInfixOf "elm-pkg-js-includes.min.js" filepath)
4953

50-
onlyWhen shouldRefresh $ Debounce.send trigger f
54+
onlyWhen shouldRefresh $ Debounce.send trigger filepath
5155
)
5256

5357
-- sleep forever (until interrupted)
5458
forever $ threadDelay 1000000
5559

60+
61+
watchFile :: FilePath -> ([FilePath] -> IO ()) -> IO ()
5662
watchFile file action =
5763
watch (FP.takeDirectory file) action

0 commit comments

Comments
 (0)