diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2011-05-28 12:41:37 +0200 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2011-05-28 12:41:37 +0200 |
commit | 6ab59438123d00b02b5a04235102df7af2926cd4 (patch) | |
tree | 9e453864d8dfd01bbfe915b33bee0289bba04d7f /src-inotify/Hakyll/Web | |
parent | b80ba8fe83220d373e639be363143cbbfd907081 (diff) | |
download | hakyll-6ab59438123d00b02b5a04235102df7af2926cd4.tar.gz |
Remove inotify bindings for now
Diffstat (limited to 'src-inotify/Hakyll/Web')
-rw-r--r-- | src-inotify/Hakyll/Web/Preview/Poll.hs | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src-inotify/Hakyll/Web/Preview/Poll.hs b/src-inotify/Hakyll/Web/Preview/Poll.hs deleted file mode 100644 index 0c27f32..0000000 --- a/src-inotify/Hakyll/Web/Preview/Poll.hs +++ /dev/null @@ -1,50 +0,0 @@ --- | Filesystem polling with an inotify backend. Works only on linux. --- -module Hakyll.Web.Preview.Poll - ( previewPoll - ) where - -import Control.Monad (forM_, when) -import Data.Set (Set) -import qualified Data.Set as S -import System.FilePath (takeDirectory, (</>)) -import Data.List (isPrefixOf) - -import System.INotify - -import Hakyll.Core.Configuration -import Hakyll.Core.Resource - --- | Calls the given callback when the directory tree changes --- -previewPoll :: HakyllConfiguration -- ^ Configuration - -> Set Resource -- ^ Resources to watch - -> IO () -- ^ Action called when something changes - -> IO () -- ^ Can block forever -previewPoll _ resources callback = do - -- Initialize inotify - inotify <- initINotify - - let -- A set of file paths - paths = S.map unResource resources - - -- A list of directories. Run it through a set so we have every - -- directory only once. - directories = S.toList $ S.map (notEmpty . takeDirectory) paths - - -- Problem: we can't add a watcher for "". So we make sure a directory - -- name is not empty - notEmpty "" = "." - notEmpty x = x - - -- Execute the callback when path is known - ifResource path = - let path' = if "./" `isPrefixOf` path then drop 2 path else path - in when (path' `S.member` paths) callback - - -- Add a watcher for every directory - forM_ directories $ \directory -> do - _ <- addWatch inotify [Modify] directory $ \e -> case e of - (Modified _ (Just p)) -> ifResource $ directory </> p - _ -> return () - return () |