summaryrefslogtreecommitdiff
path: root/Annex/NumCopies.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-10-08 16:55:11 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-10-08 16:55:11 -0400
commitd5494842274030d21356c7492e6de5969173c34d (patch)
treea1c25eacba4e6b98b0b1bf275a89ecc7ea0e20d2 /Annex/NumCopies.hs
parent55fb90edfc8732b08bea9239a6f4a471ac7867c3 (diff)
add VerifiedCopy data type
There should be no behavior changes in this commit, it just adds a more expressive data type and adjusts code that had been passing around a [UUID] or sometimes a Maybe Remote to instead use [VerifiedCopy]. Although, since some functions were taking two different [UUID] lists, there's some potential for me to have gotten it horribly wrong.
Diffstat (limited to 'Annex/NumCopies.hs')
-rw-r--r--Annex/NumCopies.hs24
1 files changed, 12 insertions, 12 deletions
diff --git a/Annex/NumCopies.hs b/Annex/NumCopies.hs
index 3f078b8f0..549c72207 100644
--- a/Annex/NumCopies.hs
+++ b/Annex/NumCopies.hs
@@ -96,11 +96,11 @@ verifyEnoughCopies
-> Key
-> NumCopies
-> [UUID] -- repos to skip considering (generally untrusted remotes)
- -> [UUID] -- repos that are trusted or already verified to have it
+ -> [VerifiedCopy] -- already known verifications
-> [Remote] -- remotes to check to see if they have it
-> Annex Bool
-verifyEnoughCopies nolocmsg key need skip trusted tocheck =
- helper [] [] (nub trusted) (nub tocheck)
+verifyEnoughCopies nolocmsg key need skip preverified tocheck =
+ helper [] [] (deDupVerifiedCopies preverified) (nub tocheck)
where
helper bad missing have []
| NumCopies (length have) >= need = return True
@@ -109,17 +109,17 @@ verifyEnoughCopies nolocmsg key need skip trusted tocheck =
return False
helper bad missing have (r:rs)
| NumCopies (length have) >= need = return True
+ | any (== u) (map toUUID have) = helper bad missing have rs
| otherwise = do
- let u = Remote.uuid r
- let duplicate = u `elem` have
haskey <- Remote.hasKey r key
- case (duplicate, haskey) of
- (False, Right True) -> helper bad missing (u:have) rs
- (False, Left _) -> helper (r:bad) missing have rs
- (False, Right False) -> helper bad (u:missing) have rs
- _ -> helper bad missing have rs
+ case haskey of
+ Right True -> helper bad missing (VerifiedCopy u:have) rs
+ Left _ -> helper (r:bad) missing have rs
+ Right False -> helper bad (u:missing) have rs
+ where
+ u = Remote.uuid r
-notEnoughCopies :: Key -> NumCopies -> [UUID] -> [UUID] -> [Remote] -> String -> Annex ()
+notEnoughCopies :: Key -> NumCopies -> [VerifiedCopy] -> [UUID] -> [Remote] -> String -> Annex ()
notEnoughCopies key need have skip bad nolocmsg = do
showNote "unsafe"
showLongNote $
@@ -127,7 +127,7 @@ notEnoughCopies key need have skip bad nolocmsg = do
show (length have) ++ " out of " ++ show (fromNumCopies need) ++
" necessary copies"
Remote.showTriedRemotes bad
- Remote.showLocations True key (have++skip) nolocmsg
+ Remote.showLocations True key (map toUUID have++skip) nolocmsg
{- Cost ordered lists of remotes that the location log indicates
- may have a key.