on master help sign in
Fix dependency edge case for singletons
commit52a06f13e726c1089000590c3ef4fb5e805fc78a authorJasper Van der Jeugt <jaspervdj@gmail.com> dateFri 13 May 2011, 19:07 (15 years ago) parent28b8420
1 file changed+8−3
src/Hakyll/Core/Run.hs+8−3
src/Hakyll/Core/Run.hs+8−3
@@ -46,8 +46,9 @@ run configuration rules = do
4646 provider <- timed logger "Creating provider" $
4747 fileResourceProvider configuration
4848
49− -- Fetch the old graph from the store
50− oldGraph <- fromMaybe mempty <$>
49+ -- Fetch the old graph from the store. If we don't find it, we consider this
50+ -- to be the first run
51+ (firstRun, oldGraph) <- fromMaybe (True, mempty) . fmap ((,) False) <$>
5152 storeGet store "Hakyll.Core.Run.run" "dependencies"
5253
5354 let ruleSet = runRules rules provider
@@ -61,6 +62,7 @@ run configuration rules = do
6162 , hakyllRoutes = rulesRoutes ruleSet
6263 , hakyllResourceProvider = provider
6364 , hakyllStore = store
65+ , hakyllFirstRun = firstRun
6466 }
6567
6668 -- Run the program and fetch the resulting state
@@ -83,6 +85,7 @@ data RuntimeEnvironment = RuntimeEnvironment
8385 , hakyllRoutes :: Routes
8486 , hakyllResourceProvider :: ResourceProvider
8587 , hakyllStore :: Store
88+ , hakyllFirstRun :: Bool
8689 }
8790
8891data RuntimeState = RuntimeState
@@ -105,6 +108,7 @@ addNewCompilers newCompilers = Runtime $ do
105108 section logger "Adding new compilers"
106109 provider <- hakyllResourceProvider <$> ask
107110 store <- hakyllStore <$> ask
111+ firstRun <- hakyllFirstRun <$> ask
108112
109113 -- Old state information
110114 oldCompilers <- hakyllCompilers <$> get
@@ -124,9 +128,10 @@ addNewCompilers newCompilers = Runtime $ do
124128 -- Check which items have been modified
125129 modified <- fmap S.fromList $ flip filterM (map fst newCompilers) $
126130 liftIO . resourceModified provider store . fromIdentifier
131+ let checkModified = if firstRun then const True else (`S.member` modified)
127132
128133 -- Create a new analyzer and append it to the currect one
129− let newAnalyzer = makeDependencyAnalyzer newGraph (`S.member` modified) $
134+ let newAnalyzer = makeDependencyAnalyzer newGraph checkModified $
130135 analyzerPreviousGraph oldAnalyzer
131136 analyzer = mappend oldAnalyzer newAnalyzer
132137