Fix dirContentsRecursive, which had missed some files in deeply nested subdirectories. Could affect various parts of git-annex.

This commit is contained in:
Joey Hess 2012-11-26 16:45:55 -04:00
parent 58f4a28f8a
commit 44a7387eba
2 changed files with 16 additions and 10 deletions

View file

@ -36,23 +36,22 @@ dirContents d = map (d </>) . filter (not . dirCruft) <$> getDirectoryContents d
- and lazily. If the directory does not exist, no exception is thrown,
- instead, [] is returned. -}
dirContentsRecursive :: FilePath -> IO [FilePath]
dirContentsRecursive topdir = dirContentsRecursive' topdir [""]
dirContentsRecursive topdir = dirContentsRecursive' [topdir]
dirContentsRecursive' :: FilePath -> [FilePath] -> IO [FilePath]
dirContentsRecursive' _ [] = return []
dirContentsRecursive' topdir (dir:dirs) = unsafeInterleaveIO $ do
(files, dirs') <- collect [] [] =<< catchDefaultIO [] (dirContents (topdir </> dir))
files' <- dirContentsRecursive' topdir (dirs' ++ dirs)
dirContentsRecursive' :: [FilePath] -> IO [FilePath]
dirContentsRecursive' [] = return []
dirContentsRecursive' (dir:dirs) = unsafeInterleaveIO $ do
(files, dirs') <- collect [] [] =<< catchDefaultIO [] (dirContents dir)
files' <- dirContentsRecursive' (dirs' ++ dirs)
return (files ++ files')
where
collect files dirs' [] = return (reverse files, reverse dirs')
collect files dirs' (entry:entries)
| dirCruft entry = collect files dirs' entries
| otherwise = do
let dirEntry = dir </> entry
ifM (doesDirectoryExist $ topdir </> dirEntry)
( collect files (dirEntry:dirs') entries
, collect (dirEntry:files) dirs' entries
ifM (doesDirectoryExist entry)
( collect files (entry:dirs') entries
, collect (entry:files) dirs' entries
)
{- Moves one filename to another.

7
debian/changelog vendored
View file

@ -1,3 +1,10 @@
git-annex (3.20121127) UNRELEASED; urgency=low
* Fix dirContentsRecursive, which had missed some files in deeply nested
subdirectories. Could affect various parts of git-annex.
-- Joey Hess <joeyh@debian.org> Mon, 26 Nov 2012 16:45:19 -0400
git-annex (3.20121126) unstable; urgency=low
* New webdav and Amazon glacier special remotes.