imp:journal:include: don't read file attributes unnecessarily
When including a literal path, don't use the Glob library at all. Glob seems to read attributes of all files in a directory, which disturbs build tools like tup which detect dependencies based on filesystem operations.
This commit is contained in:
parent
05b1798b7e
commit
48620c8e8c
@ -388,19 +388,25 @@ includedirectivep iopts = do
|
|||||||
|
|
||||||
-- Make ** also match file name parts like zsh's GLOB_STAR_SHORT.
|
-- Make ** also match file name parts like zsh's GLOB_STAR_SHORT.
|
||||||
let
|
let
|
||||||
expandedglob' =
|
finalglob =
|
||||||
-- ** without a slash is equivalent to **/*
|
-- ** without a slash is equivalent to **/*
|
||||||
case regexReplace (toRegex' $ T.pack "\\*\\*([^/\\])") "**/*\\1" expandedglob of
|
case regexReplace (toRegex' $ T.pack "\\*\\*([^/\\])") "**/*\\1" expandedglob of
|
||||||
Right s -> s
|
Right s -> s
|
||||||
Left _ -> expandedglob -- ignore any error, there should be none
|
Left _ -> expandedglob -- ignore any error, there should be none
|
||||||
|
|
||||||
-- Compile as a Pattern. Can throw an error.
|
-- Compile as a Pattern. Can throw an error.
|
||||||
g <- case tryCompileWith compDefault{errorRecovery=False} expandedglob' of
|
pat <- case tryCompileWith compDefault{errorRecovery=False} finalglob of
|
||||||
Left e -> customFailure $ parseErrorAt off $ "Invalid glob pattern: " ++ e
|
Left e -> customFailure $ parseErrorAt off $ "Invalid glob pattern: " ++ e
|
||||||
Right x -> pure x
|
Right x -> pure x
|
||||||
|
|
||||||
-- Find all matched paths. These might include directories or the current file.
|
-- Find all matched paths. These might include directories or the current file.
|
||||||
paths <- liftIO $ globDir1 g cwd
|
-- Glob seems to get attributes of all files in a directory, which disturbs build systems
|
||||||
|
-- which detect dependencies based on filesystem operations (eg tup).
|
||||||
|
-- So avoid using it if not needed.
|
||||||
|
paths <- liftIO $
|
||||||
|
if isLiteral pat
|
||||||
|
then return $ if isAbsolute finalglob then [finalglob] else [cwd </> finalglob]
|
||||||
|
else globDir1 pat cwd
|
||||||
|
|
||||||
-- Exclude any directories or symlinks to directories, and canonicalise, and sort.
|
-- Exclude any directories or symlinks to directories, and canonicalise, and sort.
|
||||||
files <- liftIO $
|
files <- liftIO $
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user