aboutsummaryrefslogtreecommitdiff
path: root/Annex
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-10-10 17:27:00 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-10-10 17:27:00 -0400
commit110c8f7b8e1fa484752298de5b48ea50b195066a (patch)
tree2bf785e8dc21b4b23046188d194431445a41e77f /Annex
parent3a48563e5258f650e6da41a90d2140bf033ce58f (diff)
queue downloads of keys that fsck finds with bad content
Diffstat (limited to 'Annex')
-rw-r--r--Annex/Content.hs16
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 []
+ )
+