on master help sign in
Ignore files sooner, small speedup
ea953d3Jasper Van der Jeugt
src/Hakyll/Check.hs+2−1
@@ -94,7 +94,8 @@ runChecker checker config verbosity check' = do
94checkDestination :: Checker ()
94checkDestination :: Checker ()
95checkDestination = do
95checkDestination = do
96 config <- checkerConfig <$> ask
96 config <- checkerConfig <$> ask
97+ files <- liftIO $
97− files <- liftIO $ getRecursiveContents (destinationDirectory config)
98+ getRecursiveContents (const False) (destinationDirectory config)
98
99
99 let htmls =
100 let htmls =
100 [ destinationDirectory config </> file
101 [ destinationDirectory config </> file
src/Hakyll/Core/Configuration.hs+1−1
@@ -37,7 +37,7 @@ data Configuration = Configuration
37 --
37 --
38 -- Note that the files in 'destinationDirectory' and 'storeDirectory' will
38 -- Note that the files in 'destinationDirectory' and 'storeDirectory' will
39 -- also be ignored. Note that this is the configuration parameter, if you
39 -- 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'.
41 --
41 --
42 ignoreFile :: FilePath -> Bool
42 ignoreFile :: FilePath -> Bool
43 , -- | Here, you can plug in a system command to upload/deploy your site.
43 , -- | 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
51 -> FilePath -- ^ Search directory
51 -> FilePath -- ^ Search directory
52 -> IO Provider -- ^ Resulting provider
52 -> IO Provider -- ^ Resulting provider
53newProvider store ignore directory = do
53newProvider store ignore directory = do
54− list <- map fromFilePath . filter (not . ignore) <$>
55− getRecursiveContents directory
54+ list <- map fromFilePath <$> getRecursiveContents ignore directory
56 cache <- newIORef M.empty
55 cache <- newIORef M.empty
57 return $ Provider directory (S.fromList list) cache store
56 return $ Provider directory (S.fromList list) cache store
58
57
src/Hakyll/Core/Util/File.hs+6−5
@@ -25,12 +25,13 @@ makeDirectories = createDirectoryIfMissing True . takeDirectory
25
25
26--------------------------------------------------------------------------------
26--------------------------------------------------------------------------------
27-- | Get all contents of a directory.
27-- | Get all contents of a directory.
28−getRecursiveContents :: FilePath -- ^ Directory to search
28+getRecursiveContents :: (FilePath -> Bool) -- ^ Ignore this file/directory
29+ -> FilePath -- ^ Directory to search
29− -> IO [FilePath] -- ^ List of files found
30+ -> IO [FilePath] -- ^ List of files found
30−getRecursiveContents top = go ""
31+getRecursiveContents ignore top = go ""
31 where
32 where
32− isProper = (`notElem` [".", ".."])
33+ isProper x = notElem x [".", ".."] && not (ignore x)
33− go dir = do
34+ go dir = do
34 dirExists <- doesDirectoryExist (top </> dir)
35 dirExists <- doesDirectoryExist (top </> dir)
35 if not dirExists
36 if not dirExists
36 then return []
37 then return []
src/Hakyll/Init.hs+1−1
@@ -23,7 +23,7 @@ main = do
23 progName <- getProgName
23 progName <- getProgName
24 args <- getArgs
24 args <- getArgs
25 srcDir <- getDataFileName "example"
25 srcDir <- getDataFileName "example"
26− files <- getRecursiveContents srcDir
26+ files <- getRecursiveContents (const False) srcDir
27
27
28 case args of
28 case args of
29 [dstDir] -> forM_ files $ \file -> do
29 [dstDir] -> forM_ files $ \file -> do