From c4f2c56f5e44d59a10b78fb49ffd28e5a8ab31ed Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 16 Jun 2020 13:54:26 -0400 Subject: [PATCH] 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. --- CHANGELOG | 4 ++- Command/CheckPresentKey.hs | 8 +++++- ...resentkey_wrongly_reports_key_absense.mdwn | 2 ++ ..._0a7bb6b12a4eb49addf443db2d16553f._comment | 26 +++++++++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 doc/bugs/checkpresentkey_wrongly_reports_key_absense/comment_2_0a7bb6b12a4eb49addf443db2d16553f._comment diff --git a/CHANGELOG b/CHANGELOG index 2fc3f50f33..f93f3c0775 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -39,7 +39,9 @@ git-annex (8.20200523) UNRELEASED; urgency=medium remotes. * When a local git remote cannot be initialized because it has no git-annex branch or a .noannex file, avoid displaying a message about it. - + * 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. -- Joey Hess Tue, 26 May 2020 10:20:52 -0400 diff --git a/Command/CheckPresentKey.hs b/Command/CheckPresentKey.hs index 55ca338e39..ca3801a111 100644 --- a/Command/CheckPresentKey.hs +++ b/Command/CheckPresentKey.hs @@ -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 diff --git a/doc/bugs/checkpresentkey_wrongly_reports_key_absense.mdwn b/doc/bugs/checkpresentkey_wrongly_reports_key_absense.mdwn index 3978b6ea3f..ebc08e239b 100644 --- a/doc/bugs/checkpresentkey_wrongly_reports_key_absense.mdwn +++ b/doc/bugs/checkpresentkey_wrongly_reports_key_absense.mdwn @@ -82,3 +82,5 @@ upgrade supported from repository versions: 0 1 2 3 4 5 6 local repository version: 5 Linux ip-172-31-85-193 4.14.97-74.72.amzn1.x86_64 #1 SMP Tue Feb 5 20:59:30 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux + +> [[fixed|done]] --[[Joey]] diff --git a/doc/bugs/checkpresentkey_wrongly_reports_key_absense/comment_2_0a7bb6b12a4eb49addf443db2d16553f._comment b/doc/bugs/checkpresentkey_wrongly_reports_key_absense/comment_2_0a7bb6b12a4eb49addf443db2d16553f._comment new file mode 100644 index 0000000000..e454d38bf7 --- /dev/null +++ b/doc/bugs/checkpresentkey_wrongly_reports_key_absense/comment_2_0a7bb6b12a4eb49addf443db2d16553f._comment @@ -0,0 +1,26 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 2""" + date="2020-06-16T17:35:41Z" + content=""" +So I guess the problem description is: + +checkpresentkey with the uuid of a remote verifies the key is on the +remote, return 1. But, with no uuid, it's supposed to check all remotes, +and instead it seems to fail and return 0 without checking the remote +whose uuid the earlier run of it showed does contain the key. + +And I think I see why it would do that. When no remote is given, it reads +the location log, and checks each remote that the location log says +contains the key. So, if the location log is out of date and a remote does +contain the key, it will return 0 w/o checking it. + +It would probably make sense for it to actually try all accessible remotes, +on the off chance one of them has the key. That's what the documentation +says it does, although I don't think it ever has. + +The original use case for this was +[[todo/checkpresentkey_without_explicit_remote]], and it does seem like +that use case intended to check all remotes, not only ones the location log +has it. +"""]]