From 5b77feb4e30a84eb76f62afe45ed4d0a17489092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= Date: Fri, 16 Sep 2016 01:29:31 +0200 Subject: [PATCH] Fix #778, findFileInParentsP: check dir perms before reading --- Language/Haskell/GhcMod/PathsAndFiles.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Language/Haskell/GhcMod/PathsAndFiles.hs b/Language/Haskell/GhcMod/PathsAndFiles.hs index ab1efd0..01f516b 100644 --- a/Language/Haskell/GhcMod/PathsAndFiles.hs +++ b/Language/Haskell/GhcMod/PathsAndFiles.hs @@ -130,10 +130,15 @@ findFileInParentsP p dir' = U.makeAbsolute' dir' >>= \dir -> -- | @getFilesP p dir@. Find all __files__ satisfying @p@ in @.cabal@ in @dir@. getFilesP :: (FilePath -> Bool) -> DirPath -> IO [FileName] -getFilesP p dir = filterM p' =<< getDirectoryContents dir +getFilesP p dir = filterM p' =<< getDirectoryContentsSafe where p' fn = do (p fn && ) <$> doesFileExist (dir fn) + getDirectoryContentsSafe = do + rdable <- readable <$> getPermissions dir + if rdable + then getDirectoryContents dir + else return [] findCabalSandboxDir :: FilePath -> IO (Maybe FilePath) findCabalSandboxDir dir = do