diff options
author | Joey Hess <joey@kitenet.net> | 2011-06-23 13:39:04 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-06-23 13:39:04 -0400 |
commit | 7ee636f6ddca4b872dde36383077875563b0b369 (patch) | |
tree | dafedf4b87647a3c6106d4deeae8888611db2511 /Remote.hs | |
parent | aec4709c3f96fa17fef2fde812ed75167ddfbc60 (diff) |
avoid unnecessary read of trust.log
Diffstat (limited to 'Remote.hs')
-rw-r--r-- | Remote.hs | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -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 |