summaryrefslogtreecommitdiff
path: root/Logs/Location.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-10-29 17:49:37 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-10-29 18:03:28 -0400
commit2566eb85fe2bbd0f9d1798d50ca0d88970a4490c (patch)
tree29cda2f8ef30eb8637c0bc7d695d3d3f77df0136 /Logs/Location.hs
parentfef2cf739872b905bbdf493f9f3ba7124400c633 (diff)
fsck: Now works in bare repositories.
Checks location log information, and file contents. Does not check that numcopies is satisfied, as .gitattributes information about numcopies is not available in a bare repository. In practice, that should not be a problem, since fsck is also run in a checkout and will check numcopies there.
Diffstat (limited to 'Logs/Location.hs')
-rw-r--r--Logs/Location.hs13
1 files changed, 13 insertions, 0 deletions
diff --git a/Logs/Location.hs b/Logs/Location.hs
index 8868912db..8855cf63b 100644
--- a/Logs/Location.hs
+++ b/Logs/Location.hs
@@ -17,6 +17,7 @@ module Logs.Location (
readLog,
keyLocations,
loggedKeys,
+ loggedKeysFor,
logFile,
logFileKey
) where
@@ -44,6 +45,18 @@ keyLocations = currentLog . logFile
loggedKeys :: Annex [Key]
loggedKeys = mapMaybe (logFileKey . takeFileName) <$> Annex.Branch.files
+{- Finds all keys that have location log information indicating
+ - they are present for the specified repository. -}
+loggedKeysFor :: UUID -> Annex [Key]
+loggedKeysFor u = filterM isthere =<< loggedKeys
+ where
+ {- This should run strictly to avoid the filterM
+ - building many thunks containing keyLocations data. -}
+ isthere k = do
+ us <- keyLocations k
+ let !there = u `elem` us
+ return there
+
{- The filename of the log file for a given key. -}
logFile :: Key -> String
logFile key = hashDirLower key ++ keyFile key ++ ".log"