diff options
Diffstat (limited to 'Annex/Content.hs')
-rw-r--r-- | Annex/Content.hs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Annex/Content.hs b/Annex/Content.hs index da0189c74..66ca7be18 100644 --- a/Annex/Content.hs +++ b/Annex/Content.hs @@ -30,6 +30,7 @@ module Annex.Content ( freezeContent, thawContent, cleanObjectLoc, + dirKeys, ) where import System.IO.Unsafe (unsafeInterleaveIO) @@ -522,3 +523,18 @@ thawContent file = unlessM crippledFileSystem $ go GroupShared = groupWriteRead file go AllShared = groupWriteRead file go _ = allowWrite file + +{- Finds files directly inside a directory like gitAnnexBadDir + - (not in subdirectories) and returns the corresponding keys. -} +dirKeys :: (Git.Repo -> FilePath) -> Annex [Key] +dirKeys dirspec = do + dir <- fromRepo dirspec + ifM (liftIO $ doesDirectoryExist dir) + ( do + contents <- liftIO $ getDirectoryContents dir + files <- liftIO $ filterM doesFileExist $ + map (dir </>) contents + return $ mapMaybe (fileKey . takeFileName) files + , return [] + ) + |