on master help sign in
Ignore files sooner, small speedup
commitea953d3415232ba53aadc061e9005dbe74e3b012 authorJasper Van der Jeugt <m@jaspervdj.be> dateWed 6 Feb 2013, 22:40 (14 years ago) parentd34d56b
5 files changed+11−10
src/Hakyll/Check.hs+2−1 src/Hakyll/Core/Configuration.hs+1−1 src/Hakyll/Core/Provider/Internal.hs+1−2 src/Hakyll/Core/Util/File.hs+6−5 src/Hakyll/Init.hs+1−1
src/Hakyll/Check.hs+2−1
@@ -94,7 +94,8 @@ runChecker checker config verbosity check' = do
9494checkDestination :: Checker ()
9595checkDestination = do
9696 config <- checkerConfig <$> ask
97− files <- liftIO $ getRecursiveContents (destinationDirectory config)
97+ files <- liftIO $
98+ getRecursiveContents (const False) (destinationDirectory config)
9899
99100 let htmls =
100101 [ destinationDirectory config </> file
src/Hakyll/Core/Configuration.hs+1−1
@@ -37,7 +37,7 @@ data Configuration = Configuration
3737 --
3838 -- Note that the files in 'destinationDirectory' and 'storeDirectory' will
3939 -- also be ignored. Note that this is the configuration parameter, if you
40− -- want to use the test, you should use 'shouldIgnoreFile'.
40+ -- want to use the test, you should use 'shouldIgnoreFile'.
4141 --
4242 ignoreFile :: FilePath -> Bool
4343 , -- | Here, you can plug in a system command to upload/deploy your site.
src/Hakyll/Core/Provider/Internal.hs+1−2
@@ -51,8 +51,7 @@ newProvider :: Store -- ^ Store to use
5151 -> FilePath -- ^ Search directory
5252 -> IO Provider -- ^ Resulting provider
5353newProvider store ignore directory = do
54− list <- map fromFilePath . filter (not . ignore) <$>
55− getRecursiveContents directory
54+ list <- map fromFilePath <$> getRecursiveContents ignore directory
5655 cache <- newIORef M.empty
5756 return $ Provider directory (S.fromList list) cache store
5857
src/Hakyll/Core/Util/File.hs+6−5
@@ -25,12 +25,13 @@ makeDirectories = createDirectoryIfMissing True . takeDirectory
2525
2626--------------------------------------------------------------------------------
2727-- | Get all contents of a directory.
28−getRecursiveContents :: FilePath -- ^ Directory to search
29− -> IO [FilePath] -- ^ List of files found
30−getRecursiveContents top = go ""
28+getRecursiveContents :: (FilePath -> Bool) -- ^ Ignore this file/directory
29+ -> FilePath -- ^ Directory to search
30+ -> IO [FilePath] -- ^ List of files found
31+getRecursiveContents ignore top = go ""
3132 where
32− isProper = (`notElem` [".", ".."])
33− go dir = do
33+ isProper x = notElem x [".", ".."] && not (ignore x)
34+ go dir = do
3435 dirExists <- doesDirectoryExist (top </> dir)
3536 if not dirExists
3637 then return []
src/Hakyll/Init.hs+1−1
@@ -23,7 +23,7 @@ main = do
2323 progName <- getProgName
2424 args <- getArgs
2525 srcDir <- getDataFileName "example"
26− files <- getRecursiveContents srcDir
26+ files <- getRecursiveContents (const False) srcDir
2727
2828 case args of
2929 [dstDir] -> forM_ files $ \file -> do