diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2013-02-06 22:40:18 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2013-02-06 22:40:18 +0100 |
commit | ea953d3415232ba53aadc061e9005dbe74e3b012 (patch) | |
tree | 10ea81bb0ddefd356d3ff84b25a5d49c8bcc5bd0 /src | |
parent | d34d56b10e14e41ad303e6c5d3daef6970af65c2 (diff) | |
download | hakyll-ea953d3415232ba53aadc061e9005dbe74e3b012.tar.gz |
Ignore files sooner, small speedup
Diffstat (limited to 'src')
-rw-r--r-- | src/Hakyll/Check.hs | 3 | ||||
-rw-r--r-- | src/Hakyll/Core/Configuration.hs | 2 | ||||
-rw-r--r-- | src/Hakyll/Core/Provider/Internal.hs | 3 | ||||
-rw-r--r-- | src/Hakyll/Core/Util/File.hs | 11 | ||||
-rw-r--r-- | src/Hakyll/Init.hs | 2 |
5 files changed, 11 insertions, 10 deletions
diff --git a/src/Hakyll/Check.hs b/src/Hakyll/Check.hs index 6b9918b..5f8f4f7 100644 --- a/src/Hakyll/Check.hs +++ b/src/Hakyll/Check.hs @@ -94,7 +94,8 @@ runChecker checker config verbosity check' = do checkDestination :: Checker () checkDestination = do config <- checkerConfig <$> ask - files <- liftIO $ getRecursiveContents (destinationDirectory config) + files <- liftIO $ + getRecursiveContents (const False) (destinationDirectory config) let htmls = [ destinationDirectory config </> file diff --git a/src/Hakyll/Core/Configuration.hs b/src/Hakyll/Core/Configuration.hs index 47de700..fdca879 100644 --- a/src/Hakyll/Core/Configuration.hs +++ b/src/Hakyll/Core/Configuration.hs @@ -37,7 +37,7 @@ data Configuration = Configuration -- -- Note that the files in 'destinationDirectory' and 'storeDirectory' will -- also be ignored. Note that this is the configuration parameter, if you - -- want to use the test, you should use 'shouldIgnoreFile'. + -- want to use the test, you should use 'shouldIgnoreFile'. -- ignoreFile :: FilePath -> Bool , -- | Here, you can plug in a system command to upload/deploy your site. diff --git a/src/Hakyll/Core/Provider/Internal.hs b/src/Hakyll/Core/Provider/Internal.hs index 1360ef5..301c25c 100644 --- a/src/Hakyll/Core/Provider/Internal.hs +++ b/src/Hakyll/Core/Provider/Internal.hs @@ -51,8 +51,7 @@ newProvider :: Store -- ^ Store to use -> FilePath -- ^ Search directory -> IO Provider -- ^ Resulting provider newProvider store ignore directory = do - list <- map fromFilePath . filter (not . ignore) <$> - getRecursiveContents directory + list <- map fromFilePath <$> getRecursiveContents ignore directory cache <- newIORef M.empty return $ Provider directory (S.fromList list) cache store diff --git a/src/Hakyll/Core/Util/File.hs b/src/Hakyll/Core/Util/File.hs index 0e34d7c..20cfbbc 100644 --- a/src/Hakyll/Core/Util/File.hs +++ b/src/Hakyll/Core/Util/File.hs @@ -25,12 +25,13 @@ makeDirectories = createDirectoryIfMissing True . takeDirectory -------------------------------------------------------------------------------- -- | Get all contents of a directory. -getRecursiveContents :: FilePath -- ^ Directory to search - -> IO [FilePath] -- ^ List of files found -getRecursiveContents top = go "" +getRecursiveContents :: (FilePath -> Bool) -- ^ Ignore this file/directory + -> FilePath -- ^ Directory to search + -> IO [FilePath] -- ^ List of files found +getRecursiveContents ignore top = go "" where - isProper = (`notElem` [".", ".."]) - go dir = do + isProper x = notElem x [".", ".."] && not (ignore x) + go dir = do dirExists <- doesDirectoryExist (top </> dir) if not dirExists then return [] diff --git a/src/Hakyll/Init.hs b/src/Hakyll/Init.hs index 3e2969e..2a92340 100644 --- a/src/Hakyll/Init.hs +++ b/src/Hakyll/Init.hs @@ -23,7 +23,7 @@ main = do progName <- getProgName args <- getArgs srcDir <- getDataFileName "example" - files <- getRecursiveContents srcDir + files <- getRecursiveContents (const False) srcDir case args of [dstDir] -> forM_ files $ \file -> do |