on master help sign in
Include the directory in the path
commitb89aad6178b151a859469a3ae5c6ed4e6f57cad6 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateSat 19 Feb 2011, 10:39 (16 years ago) parent4c75843
1 file changed+7−8
src/Hakyll/Web/Preview/INotify.hs+7−8
src/Hakyll/Web/Preview/INotify.hs+7−8
@@ -7,7 +7,7 @@ module Hakyll.Web.Preview.INotify
77import Control.Monad (forM_, when)
88import Data.Set (Set)
99import qualified Data.Set as S
10−import System.FilePath (takeDirectory)
10+import System.FilePath (takeDirectory, (</>))
1111
1212import System.INotify
1313
@@ -28,10 +28,12 @@ previewPoll _ resources callback = do
2828 let -- A set of file paths
2929 paths = S.map (toFilePath . unResource) resources
3030
31− -- A list of directories
31+ -- A list of directories. Run it through a set so we have every
32+ -- directory only once.
3233 directories = S.toList $ S.map (notEmpty . takeDirectory) paths
3334
34− -- Make sure a directory name is not empty
35+ -- Problem: we can't add a watcher for "". So we make sure a directory
36+ -- name is not empty
3537 notEmpty "" = "."
3638 notEmpty x = x
3739
@@ -43,10 +45,7 @@ previewPoll _ resources callback = do
4345 -- Add a watcher for every directory
4446 forM_ directories $ \directory -> do
4547 putStrLn $ "Adding watch for " ++ directory
46− _ <- addWatch inotify interesting directory $ \e -> case e of
47− (Modified _ (Just p)) -> ifResource p
48+ _ <- addWatch inotify [Modify] directory $ \e -> case e of
49+ (Modified _ (Just p)) -> ifResource $ directory </> p
4850 _ -> return ()
4951 return ()
50− where
51− -- Interesting events
52− interesting = [Modify]