From 40c75767d4f926de4ce2fd3db688e46987fb8b72 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Mon, 3 Jan 2011 11:33:59 +0100 Subject: Store modified flags in a map This allows reuse for actual dependency checking (to be implemented later). --- src/Hakyll/Core/Run.hs | 18 ++++++++++++------ 1 file 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') -- cgit v1.2.3