on b287c82 help sign in
hakyll/src/Hakyll/Core/Provider.hs
43 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.resourceFilePath
13 , Internal.resourceModified
14 , Internal.resourceModificationTime
16 -- * Access to raw resource content
17 , Internal.resourceString
18 , Internal.resourceLBS
20 -- * Access to metadata and body content
21 , Internal.resourceMetadata
22 , Internal.resourceBody
23 ) where
26--------------------------------------------------------------------------------
27import qualified Hakyll.Core.Provider.Internal as Internal
28import qualified Hakyll.Core.Provider.MetadataCache as Internal
29import Hakyll.Core.Store (Store)
32--------------------------------------------------------------------------------
33-- | Create a resource provider
34newProvider :: Store -- ^ Store to use
35 -> (FilePath -> Bool) -- ^ Should we ignore this file?
36 -> FilePath -- ^ Search directory
37 -> IO Internal.Provider -- ^ Resulting provider
38newProvider store ignore directory = do
39 -- Delete metadata cache where necessary
40 p <- Internal.newProvider store ignore directory
41 mapM_ (Internal.resourceInvalidateMetadataCache p) $
42 filter (Internal.resourceModified p) $ Internal.resourceList p
43 return p