diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2011-04-12 10:09:03 +0200 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2011-04-12 10:09:03 +0200 |
commit | b37da38d3911bbc8381a39fe526e69599d9ddcf1 (patch) | |
tree | d27f2dbf8860ddbdf0d791aff77dd8504ba6da92 /src/Hakyll/Core/Resource | |
parent | 0a3cd37cc9635d2d1e6696bff91dcd37e81bd202 (diff) | |
download | hakyll-b37da38d3911bbc8381a39fe526e69599d9ddcf1.tar.gz |
Major refactoring of identifiers/resources/groups
Diffstat (limited to 'src/Hakyll/Core/Resource')
-rw-r--r-- | src/Hakyll/Core/Resource/Provider.hs | 12 | ||||
-rw-r--r-- | src/Hakyll/Core/Resource/Provider/File.hs | 9 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/Hakyll/Core/Resource/Provider.hs b/src/Hakyll/Core/Resource/Provider.hs index 67299a6..cb70cf9 100644 --- a/src/Hakyll/Core/Resource/Provider.hs +++ b/src/Hakyll/Core/Resource/Provider.hs @@ -27,7 +27,6 @@ import qualified Data.ByteString.Lazy as LB import OpenSSL.Digest.ByteString.Lazy (digest) import OpenSSL.Digest (MessageDigest (MD5)) -import Hakyll.Core.Identifier import Hakyll.Core.Store import Hakyll.Core.Resource @@ -46,8 +45,8 @@ data ResourceProvider = ResourceProvider -- | Check if a given identifier has a resource -- -resourceExists :: ResourceProvider -> Identifier -> Bool -resourceExists provider = flip elem $ map unResource $ resourceList provider +resourceExists :: ResourceProvider -> Resource -> Bool +resourceExists provider = flip elem $ resourceList provider -- | Retrieve a digest for a given resource -- @@ -64,7 +63,7 @@ resourceModified provider store resource = do Just m -> return m -- Not yet in the cache, check digests (if it exists) Nothing -> do - m <- if resourceExists provider (unResource resource) + m <- if resourceExists provider resource then digestModified provider store resource else return False modifyMVar_ mvar (return . M.insert resource m) @@ -77,7 +76,7 @@ resourceModified provider store resource = do digestModified :: ResourceProvider -> Store -> Resource -> IO Bool digestModified provider store resource = do -- Get the latest seen digest from the store - lastDigest <- storeGet store itemName $ unResource resource + lastDigest <- storeGet store itemName identifier -- Calculate the digest for the resource newDigest <- resourceDigest provider resource -- Check digests @@ -85,7 +84,8 @@ digestModified provider store resource = do -- All is fine, not modified then return False -- Resource modified; store new digest - else do storeSet store itemName (unResource resource) newDigest + else do storeSet store itemName identifier newDigest return True where + identifier = toIdentifier resource itemName = "Hakyll.Core.ResourceProvider.digestModified" diff --git a/src/Hakyll/Core/Resource/Provider/File.hs b/src/Hakyll/Core/Resource/Provider/File.hs index 953d61c..5383b51 100644 --- a/src/Hakyll/Core/Resource/Provider/File.hs +++ b/src/Hakyll/Core/Resource/Provider/File.hs @@ -12,7 +12,6 @@ import qualified Data.ByteString.Lazy as LB import Hakyll.Core.Resource import Hakyll.Core.Resource.Provider -import Hakyll.Core.Identifier import Hakyll.Core.Util.File import Hakyll.Core.Configuration @@ -20,8 +19,8 @@ import Hakyll.Core.Configuration -- fileResourceProvider :: HakyllConfiguration -> IO ResourceProvider fileResourceProvider configuration = do - -- Retrieve a list of identifiers - list <- map parseIdentifier . filter (not . ignoreFile configuration) <$> + -- Retrieve a list of paths + list <- filter (not . ignoreFile configuration) <$> getRecursiveContents False "." -- MVar for the cache @@ -30,7 +29,7 @@ fileResourceProvider configuration = do -- Construct a resource provider return ResourceProvider { resourceList = map Resource list - , resourceString = readFile . toFilePath . unResource - , resourceLazyByteString = LB.readFile . toFilePath . unResource + , resourceString = readFile . unResource + , resourceLazyByteString = LB.readFile . unResource , resourceModifiedCache = mvar } |