summaryrefslogtreecommitdiff
path: root/Remote.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-06-23 13:39:04 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-06-23 13:39:04 -0400
commit7ee636f6ddca4b872dde36383077875563b0b369 (patch)
treedafedf4b87647a3c6106d4deeae8888611db2511 /Remote.hs
parentaec4709c3f96fa17fef2fde812ed75167ddfbc60 (diff)
avoid unnecessary read of trust.log
Diffstat (limited to 'Remote.hs')
-rw-r--r--Remote.hs22
1 files changed, 20 insertions, 2 deletions
diff --git a/Remote.hs b/Remote.hs
index 512242342..6295fc947 100644
--- a/Remote.hs
+++ b/Remote.hs
@@ -15,6 +15,7 @@ module Remote (
hasKey,
hasKeyCheap,
keyPossibilities,
+ keyPossibilitiesTrusted,
forceTrust,
remoteTypes,
@@ -128,12 +129,29 @@ remotesWithoutUUID :: [Remote Annex] -> [UUID] -> [Remote Annex]
remotesWithoutUUID rs us = filter (\r -> uuid r `notElem` us) rs
{- Cost ordered lists of remotes that the LocationLog indicate may have a key.
+ -}
+keyPossibilities :: Key -> Annex [Remote Annex]
+keyPossibilities key = do
+ g <- Annex.gitRepo
+ u <- getUUID g
+
+ -- get uuids of all remotes that are recorded to have the key
+ uuids <- keyLocations key
+ let validuuids = filter (/= u) uuids
+
+ -- remotes that match uuids that have the key
+ allremotes <- genList
+ let validremotes = remotesWithUUID allremotes validuuids
+
+ return $ sort validremotes
+
+{- Cost ordered lists of remotes that the LocationLog indicate may have a key.
-
- Also returns a list of UUIDs that are trusted to have the key
- (some may not have configured remotes).
-}
-keyPossibilities :: Key -> Annex ([Remote Annex], [UUID])
-keyPossibilities key = do
+keyPossibilitiesTrusted :: Key -> Annex ([Remote Annex], [UUID])
+keyPossibilitiesTrusted key = do
g <- Annex.gitRepo
u <- getUUID g
trusted <- trustGet Trusted