@@ -3,12 +3,12 @@ module Hakyll.Preview.Poll
5--------------------------------------------------------------------------------
5--------------------------------------------------------------------------------
6−import Control.Concurrent (threadDelay)
7import Control.Monad (void)
6import Control.Monad (void)
8import Data.List (isPrefixOf)
7import Data.List (isPrefixOf)
9import Filesystem.Path.CurrentOS (decodeString, encodeString)
8import Filesystem.Path.CurrentOS (decodeString, encodeString)
10import System.Directory (canonicalizePath)
9import System.Directory (canonicalizePath)
11−import System.FSNotify (withManagerConf, watchTree, Event(..), WatchConfig(..))
10+import System.FSNotify (startManagerConf, watchTree,
11+ Event(..), WatchConfig(..))
12import System.IO.Error (catchIOError)
12import System.IO.Error (catchIOError)
14--------------------------------------------------------------------------------
14--------------------------------------------------------------------------------
@@ -21,7 +21,7 @@ import Hakyll.Core.Configuration
21previewPoll :: Configuration -- ^ Configuration
21previewPoll :: Configuration -- ^ Configuration
22 -> IO [FilePath] -- ^ Updating action
22 -> IO [FilePath] -- ^ Updating action
23 -> IO () -- ^ Can block forever
23 -> IO () -- ^ Can block forever
24−previewPoll conf update = withManagerConf (Debounce 0.1) monitor
24+previewPoll conf update = monitor =<< startManagerConf (Debounce 0.1)
26 path = decodeString $ providerDirectory conf
26 path = decodeString $ providerDirectory conf
27 monitor manager = do
27 monitor manager = do
@@ -29,7 +29,6 @@ previewPoll conf update = withManagerConf (Debounce 0.1) monitor
29 ignore <- mapM getPath
29 ignore <- mapM getPath
30 [destinationDirectory, storeDirectory, tmpDirectory]
30 [destinationDirectory, storeDirectory, tmpDirectory]
31 watchTree manager path (predicate ignore) (\_ -> void update)
31 watchTree manager path (predicate ignore) (\_ -> void update)
33 getPath fn = catchIOError (canonicalizePath $ fn conf)
32 getPath fn = catchIOError (canonicalizePath $ fn conf)
34 (const $ return $ fn conf)
33 (const $ return $ fn conf)
35 predicate ignore evt
34 predicate ignore evt
@@ -38,11 +37,6 @@ previewPoll conf update = withManagerConf (Debounce 0.1) monitor
38 | (ignoreFile conf) (eventPath evt) == True = False
37 | (ignoreFile conf) (eventPath evt) == True = False
39 | otherwise = True
38 | otherwise = True
46eventPath :: Event -> FilePath
40eventPath :: Event -> FilePath
47eventPath (Added p _) = encodeString p
41eventPath (Added p _) = encodeString p
48eventPath (Modified p _) = encodeString p
42eventPath (Modified p _) = encodeString p