summaryrefslogtreecommitdiff
path: root/src/Hakyll/Core
diff options
context:
space:
mode:
Diffstat (limited to 'src/Hakyll/Core')
-rw-r--r--src/Hakyll/Core/Provider/MetadataCache.hs8
-rw-r--r--src/Hakyll/Core/Store.hs16
2 files changed, 11 insertions, 13 deletions
diff --git a/src/Hakyll/Core/Provider/MetadataCache.hs b/src/Hakyll/Core/Provider/MetadataCache.hs
index 031960c..28d2bd5 100644
--- a/src/Hakyll/Core/Provider/MetadataCache.hs
+++ b/src/Hakyll/Core/Provider/MetadataCache.hs
@@ -7,8 +7,8 @@ module Hakyll.Core.Provider.MetadataCache
--------------------------------------------------------------------------------
+import Control.Monad (unless)
import qualified Data.Map as M
-import Control.Monad (unless)
--------------------------------------------------------------------------------
import Hakyll.Core.Identifier
@@ -51,9 +51,9 @@ load :: Provider -> Identifier -> IO ()
load p r = do
mmof <- Store.isMember store mdk
unless mmof $ do
- (md, body) <- loadMetadata p r
- Store.set store mdk md
- Store.set store bk body
+ (md, body) <- loadMetadata p r
+ Store.set store mdk md
+ Store.set store bk body
where
store = providerStore p
mdk = [name, toFilePath r, "metadata"]
diff --git a/src/Hakyll/Core/Store.hs b/src/Hakyll/Core/Store.hs
index b2c61a0..74d9d2f 100644
--- a/src/Hakyll/Core/Store.hs
+++ b/src/Hakyll/Core/Store.hs
@@ -24,6 +24,7 @@ import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as BL
import qualified Data.Cache.LRU.IO as Lru
import Data.List (intercalate)
+import Data.Maybe (isJust)
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import Data.Typeable (TypeRep, Typeable, cast, typeOf)
@@ -103,12 +104,8 @@ cacheLookup (Store _ (Just lru)) key = do
--------------------------------------------------------------------------------
cacheIsMember :: Store -> String -> IO Bool
-cacheIsMember (Store _ Nothing) _ = return False
-cacheIsMember (Store _ (Just lru)) key = do
- res <- Lru.lookup key lru
- case res of
- Nothing -> return False
- _ -> return True
+cacheIsMember (Store _ Nothing) _ = return False
+cacheIsMember (Store _ (Just lru)) key = isJust <$> Lru.lookup key lru
--------------------------------------------------------------------------------
@@ -168,9 +165,10 @@ isMember :: Store -> [String] -> IO Bool
isMember store identifier = do
inCache <- cacheIsMember store key
if inCache then return True else doesFileExist path
- where
- key = hash identifier
- path = storeDirectory store </> key
+ where
+ key = hash identifier
+ path = storeDirectory store </> key
+
--------------------------------------------------------------------------------
-- | Delete an item