diff options
| author | Simonas Kazlauskas <git@kazlauskas.me> | 2013-03-30 17:24:20 +0200 |
|---|---|---|
| committer | Simonas Kazlauskas <git@kazlauskas.me> | 2013-03-30 17:48:36 +0200 |
| commit | fdfbf3dd344318dbb4f104644c6b952e48df294c (patch) | |
| tree | 3ef901cd17ed5ae84db20cbb9e63236d51074a35 /src/Hakyll/Preview | |
| parent | 42cdd649db36d6be52d297be36bedfc1f3ba8ee7 (diff) | |
| download | hakyll-fdfbf3dd344318dbb4f104644c6b952e48df294c.tar.gz | |
Run server in main thread
Diffstat (limited to 'src/Hakyll/Preview')
| -rw-r--r-- | src/Hakyll/Preview/Poll.hs | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/Hakyll/Preview/Poll.hs b/src/Hakyll/Preview/Poll.hs index c6c9b9a..e9920ad 100644 --- a/src/Hakyll/Preview/Poll.hs +++ b/src/Hakyll/Preview/Poll.hs @@ -3,12 +3,12 @@ module Hakyll.Preview.Poll ) where -------------------------------------------------------------------------------- -import Control.Concurrent (threadDelay) import Control.Monad (void) import Data.List (isPrefixOf) import Filesystem.Path.CurrentOS (decodeString, encodeString) import System.Directory (canonicalizePath) -import System.FSNotify (withManagerConf, watchTree, Event(..), WatchConfig(..)) +import System.FSNotify (startManagerConf, watchTree, + Event(..), WatchConfig(..)) import System.IO.Error (catchIOError) -------------------------------------------------------------------------------- @@ -21,7 +21,7 @@ import Hakyll.Core.Configuration previewPoll :: Configuration -- ^ Configuration -> IO [FilePath] -- ^ Updating action -> IO () -- ^ Can block forever -previewPoll conf update = withManagerConf (Debounce 0.1) monitor +previewPoll conf update = monitor =<< startManagerConf (Debounce 0.1) where path = decodeString $ providerDirectory conf monitor manager = do @@ -29,7 +29,6 @@ previewPoll conf update = withManagerConf (Debounce 0.1) monitor ignore <- mapM getPath [destinationDirectory, storeDirectory, tmpDirectory] watchTree manager path (predicate ignore) (\_ -> void update) - infiniteLoop getPath fn = catchIOError (canonicalizePath $ fn conf) (const $ return $ fn conf) predicate ignore evt @@ -38,11 +37,6 @@ previewPoll conf update = withManagerConf (Debounce 0.1) monitor | (ignoreFile conf) (eventPath evt) == True = False | otherwise = True -infiniteLoop :: IO () -infiniteLoop = do - threadDelay maxBound - infiniteLoop - eventPath :: Event -> FilePath eventPath (Added p _) = encodeString p eventPath (Modified p _) = encodeString p |
