diff options
-rw-r--r-- | src/Hakyll/Core/Run.hs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/Hakyll/Core/Run.hs b/src/Hakyll/Core/Run.hs index 1b45f38..6898b3a 100644 --- a/src/Hakyll/Core/Run.hs +++ b/src/Hakyll/Core/Run.hs @@ -3,12 +3,13 @@ module Hakyll.Core.Run where import Control.Arrow ((&&&)) -import Control.Monad (foldM, forM_) +import Control.Monad (foldM, forM_, forM) import qualified Data.Map as M import Data.Monoid (mempty) import Data.Typeable (Typeable) import Data.Binary (Binary) import System.FilePath ((</>)) +import Control.Applicative ((<$>)) import Hakyll.Core.Route import Hakyll.Core.Identifier @@ -60,18 +61,23 @@ hakyllWith rules provider store = do putStrLn "Writing dependency graph to dependencies.dot..." writeDot "dependencies.dot" show graph + -- Check which items are up-to-date: modified will be a Map Identifier Bool + modifiedMap <- fmap M.fromList $ forM orderedCompilers $ \(id', _) -> do + modified <- if resourceExists provider id' + then resourceModified provider id' store + else return False + return (id', modified) + -- Generate all the targets in order - _ <- foldM (addTarget route') M.empty orderedCompilers + _ <- foldM (addTarget route' modifiedMap) M.empty orderedCompilers putStrLn "DONE." where - addTarget route' map' (id', comp) = do + addTarget route' modifiedMap map' (id', comp) = do let url = runRoute route' id' -- Check if the resource was modified - modified <- if resourceExists provider id' - then resourceModified provider id' store - else return False + let modified = modifiedMap M.! id' -- Run the compiler compiled <- runCompilerJob comp id' provider (dependencyLookup map') |