on b91c8be help sign in
hakyll/src/Hakyll/Core/Provider.hs
42 lines 1.6 kB history raw
1--------------------------------------------------------------------------------
2-- | This module provides an wrapper API around the file system which does some
3-- caching.
4module Hakyll.Core.Provider
5 ( -- * Constructing resource providers
6 Internal.Provider
7 , newProvider
9 -- * Querying resource properties
10 , Internal.resourceList
11 , Internal.resourceExists
12 , Internal.resourceModified
13 , Internal.resourceModificationTime
15 -- * Access to raw resource content
16 , Internal.resourceString
17 , Internal.resourceLBS
19 -- * Access to metadata and body content
20 , Internal.resourceMetadata
21 , Internal.resourceBody
22 ) where
25--------------------------------------------------------------------------------
26import qualified Hakyll.Core.Provider.Internal as Internal
27import qualified Hakyll.Core.Provider.MetadataCache as Internal
28import Hakyll.Core.Store (Store)
31--------------------------------------------------------------------------------
32-- | Create a resource provider
33newProvider :: Store -- ^ Store to use
34 -> (FilePath -> Bool) -- ^ Should we ignore this file?
35 -> FilePath -- ^ Search directory
36 -> IO Internal.Provider -- ^ Resulting provider
37newProvider store ignore directory = do
38 -- Delete metadata cache where necessary
39 p <- Internal.newProvider store ignore directory
40 mapM_ (Internal.resourceInvalidateMetadataCache p) $
41 filter (Internal.resourceModified p) $ Internal.resourceList p
42 return p