diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-12-31 12:18:33 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-12-31 12:18:33 +0100 |
commit | 70c7363b8c1ad250c5f68993867015ef68a8b46c (patch) | |
tree | 429bab77ed70027d0e8bd5886900a688ac2abe3f /src/Hakyll/Core | |
parent | 7b84181dab7c45c48be5db5b68e31ad5880b05cc (diff) | |
download | hakyll-70c7363b8c1ad250c5f68993867015ef68a8b46c.tar.gz |
Add wasModified method
Diffstat (limited to 'src/Hakyll/Core')
-rw-r--r-- | src/Hakyll/Core/Store.hs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/Hakyll/Core/Store.hs b/src/Hakyll/Core/Store.hs index 02b9b4e..7e57df2 100644 --- a/src/Hakyll/Core/Store.hs +++ b/src/Hakyll/Core/Store.hs @@ -5,6 +5,7 @@ module Hakyll.Core.Store , makeStore , storeSet , storeGet + , wasModified ) where import Control.Applicative ((<$>)) @@ -15,6 +16,7 @@ import Data.Binary (Binary, encodeFile, decodeFile) import Hakyll.Core.Identifier import Hakyll.Core.Util.File +import Hakyll.Core.ResourceProvider -- | Data structure used for the store -- @@ -51,3 +53,21 @@ storeGet store name identifier = do else return Nothing where path = makePath store name identifier + +-- | Check if a resource was modified +-- +wasModified :: Store -> ResourceProvider -> Identifier -> IO Bool +wasModified store provider identifier = do + -- Get the latest seen digest from the store + lastDigest <- storeGet store itemName identifier + -- Calculate the digest for the resource + newDigest <- resourceDigest provider identifier + -- Check digests + if Just newDigest == lastDigest + -- All is fine, not modified + then return False + -- Resource modified; store new digest + else do storeSet store itemName identifier newDigest + return True + where + itemName = "Hakyll.Core.Store.wasModified" |