checkpresentkey: fix behavior to match documentation

checkpresentkey: When no remote is specified, try all remotes, not only
ones that the location log says contain the key. This is what the
documentation has always said it did.

Still try the logged remotes first, because they are far more likely to
have the key.
This commit is contained in:
Joey Hess 2020-06-16 13:54:26 -04:00
parent f3010afbf6
commit c4f2c56f5e
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 38 additions and 2 deletions

View file

@ -9,6 +9,7 @@ module Command.CheckPresentKey where
import Command
import qualified Remote
import Remote.List
cmd :: Command
cmd = noCommit $ noMessages $
@ -46,8 +47,13 @@ data Result = Present | NotPresent | CheckFailure String
check :: String -> Maybe Remote -> Annex Result
check ks mr = case mr of
Nothing -> go Nothing =<< Remote.keyPossibilities k
Just r -> go Nothing [r]
Nothing -> do
mostlikely <- Remote.keyPossibilities k
otherremotes <- flip Remote.remotesWithoutUUID
(map Remote.uuid mostlikely)
<$> remoteList
go Nothing (mostlikely ++ otherremotes)
where
k = toKey ks
go Nothing [] = return NotPresent