summaryrefslogtreecommitdiff
path: root/Remote.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-10-09 14:57:32 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-10-09 14:57:32 -0400
commitd6831bd8f2bd4e4c518d0779895c990268c17777 (patch)
tree595f33bf3a8ec7a5ce1a2d026c0f2a9dddece77f /Remote.hs
parent4f9957f5342c58adf5b406122b6a8157352ab89b (diff)
verify local copy of content with locking
Diffstat (limited to 'Remote.hs')
-rw-r--r--Remote.hs33
1 files changed, 13 insertions, 20 deletions
diff --git a/Remote.hs b/Remote.hs
index 57a22f36b..c38262a33 100644
--- a/Remote.hs
+++ b/Remote.hs
@@ -40,7 +40,7 @@ module Remote (
remotesWithoutUUID,
keyLocations,
keyPossibilities,
- keyPossibilitiesTrusted,
+ remoteLocations,
nameToUUID,
nameToUUID',
showTriedRemotes,
@@ -260,33 +260,26 @@ keyLocations key = trustExclude DeadTrusted =<< loggedLocations key
- may have a key.
-}
keyPossibilities :: Key -> Annex [Remote]
-keyPossibilities key = fst <$> keyPossibilities' key []
-
-{- Cost ordered lists of remotes that the location log indicates
- - may have a key.
- -
- - Also returns a list of UUIDs that are trusted to have the key
- - (some may not have configured remotes).
- -}
-keyPossibilitiesTrusted :: Key -> Annex ([Remote], [UUID])
-keyPossibilitiesTrusted key = keyPossibilities' key =<< trustGet Trusted
-
-keyPossibilities' :: Key -> [UUID] -> Annex ([Remote], [UUID])
-keyPossibilities' key trusted = do
+keyPossibilities key = do
u <- getUUID
-
-- uuids of all remotes that are recorded to have the key
- validuuids <- filter (/= u) <$> keyLocations key
+ locations <- filter (/= u) <$> keyLocations key
+ fst <$> remoteLocations locations []
- -- note that validuuids is assumed to not have dups
- let validtrusteduuids = validuuids `intersect` trusted
+{- Given a list of locations of a key, and a list of all
+ - trusted repositories, generates a cost-ordered list of
+ - remotes that contain the key, and a list of trusted locations of the key.
+ -}
+remoteLocations :: [UUID] -> [UUID] -> Annex ([Remote], [UUID])
+remoteLocations locations trusted = do
+ let validtrustedlocations = nub locations `intersect` trusted
-- remotes that match uuids that have the key
allremotes <- filter (not . remoteAnnexIgnore . gitconfig)
<$> remoteList
- let validremotes = remotesWithUUID allremotes validuuids
+ let validremotes = remotesWithUUID allremotes locations
- return (sortBy (comparing cost) validremotes, validtrusteduuids)
+ return (sortBy (comparing cost) validremotes, validtrustedlocations)
{- Displays known locations of a key. -}
showLocations :: Bool -> Key -> [UUID] -> String -> Annex ()