Fix #778, findFileInParentsP: check dir perms before reading
This commit is contained in:
parent
4bea7d5a85
commit
5b77feb4e3
@ -130,10 +130,15 @@ findFileInParentsP p dir' = U.makeAbsolute' dir' >>= \dir ->
|
|||||||
|
|
||||||
-- | @getFilesP p dir@. Find all __files__ satisfying @p@ in @.cabal@ in @dir@.
|
-- | @getFilesP p dir@. Find all __files__ satisfying @p@ in @.cabal@ in @dir@.
|
||||||
getFilesP :: (FilePath -> Bool) -> DirPath -> IO [FileName]
|
getFilesP :: (FilePath -> Bool) -> DirPath -> IO [FileName]
|
||||||
getFilesP p dir = filterM p' =<< getDirectoryContents dir
|
getFilesP p dir = filterM p' =<< getDirectoryContentsSafe
|
||||||
where
|
where
|
||||||
p' fn = do
|
p' fn = do
|
||||||
(p fn && ) <$> doesFileExist (dir </> fn)
|
(p fn && ) <$> doesFileExist (dir </> fn)
|
||||||
|
getDirectoryContentsSafe = do
|
||||||
|
rdable <- readable <$> getPermissions dir
|
||||||
|
if rdable
|
||||||
|
then getDirectoryContents dir
|
||||||
|
else return []
|
||||||
|
|
||||||
findCabalSandboxDir :: FilePath -> IO (Maybe FilePath)
|
findCabalSandboxDir :: FilePath -> IO (Maybe FilePath)
|
||||||
findCabalSandboxDir dir = do
|
findCabalSandboxDir dir = do
|
||||||
|
Loading…
Reference in New Issue
Block a user