@@ -3,12 +3,12 @@ module Hakyll.Preview.Poll
33 ) where
44
55--------------------------------------------------------------------------------
6−import Control.Concurrent (threadDelay)
76import Control.Monad (void)
87import Data.List (isPrefixOf)
98import Filesystem.Path.CurrentOS (decodeString, encodeString)
109import System.Directory (canonicalizePath)
11−import System.FSNotify (withManagerConf, watchTree, Event(..), WatchConfig(..))
10+import System.FSNotify (startManagerConf, watchTree,
11+ Event(..), WatchConfig(..))
1212import System.IO.Error (catchIOError)
1313
1414--------------------------------------------------------------------------------
@@ -21,7 +21,7 @@ import Hakyll.Core.Configuration
2121previewPoll :: Configuration -- ^ Configuration
2222 -> IO [FilePath] -- ^ Updating action
2323 -> IO () -- ^ Can block forever
24−previewPoll conf update = withManagerConf (Debounce 0.1) monitor
24+previewPoll conf update = monitor =<< startManagerConf (Debounce 0.1)
2525 where
2626 path = decodeString $ providerDirectory conf
2727 monitor manager = do
@@ -29,7 +29,6 @@ previewPoll conf update = withManagerConf (Debounce 0.1) monitor
2929 ignore <- mapM getPath
3030 [destinationDirectory, storeDirectory, tmpDirectory]
3131 watchTree manager path (predicate ignore) (\_ -> void update)
32− infiniteLoop
3332 getPath fn = catchIOError (canonicalizePath $ fn conf)
3433 (const $ return $ fn conf)
3534 predicate ignore evt
@@ -38,11 +37,6 @@ previewPoll conf update = withManagerConf (Debounce 0.1) monitor
3837 | (ignoreFile conf) (eventPath evt) == True = False
3938 | otherwise = True
4039
41−infiniteLoop :: IO ()
42−infiniteLoop = do
43− threadDelay maxBound
44− infiniteLoop
45−
4640eventPath :: Event -> FilePath
4741eventPath (Added p _) = encodeString p
4842eventPath (Modified p _) = encodeString p