From f29d49d47804cd1b6a54ad920b4a6ab44e390886 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 15 Dec 2020 14:44:00 -0400 Subject: [PATCH] check Remote.hasKeyCheap again In cd1676d604, it stopped using that to avoid surprising behavior when the location log and remote content were out of sync. But, it seems that may have changed some behavior users relied on as well, and also Remote.hasKeyCheap should be faster than checking then location log. So, try Remote.hasKeyCheap first, and only if it does not have the key, fall back to checking the location log. If the location log still thinks it's present, go ahead and try to get it, so the user will see a failure rather than silently skipping a file what whereis says is on the remote. This does make slightly slower the case where the remote does not have the key, and location log and Remote.hasKeyCheap agree, since it now checks both. But only 1 stat slower. --- Command/Move.hs | 20 +++++++++++++++---- ..._536adad665f481a15d4096360d0106c1._comment | 10 ++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 doc/forum/What_is_going_on_here__63__/comment_6_536adad665f481a15d4096360d0106c1._comment diff --git a/Command/Move.hs b/Command/Move.hs index 71e2951700..584565648a 100644 --- a/Command/Move.hs +++ b/Command/Move.hs @@ -207,10 +207,22 @@ fromStart removewhen afile key ai si src = fromPerform src removewhen key afile fromOk :: Remote -> Key -> Annex Bool -fromOk src key = do - u <- getUUID - remotes <- Remote.keyPossibilities key - return $ u /= Remote.uuid src && elem src remotes +fromOk src key + -- check if the remote contains the key, when it can be done cheaply + | Remote.hasKeyCheap src = + Remote.hasKey src key >>= + Right True -> return True + -- Don't skip getting the key just because the + -- remote no longer contains it if the log + -- says the remote is supposed to contain it; + -- that would be surprising behavior. + _ -> checklog + | otherwise = checklog + where + checklog = do + u <- getUUID + remotes <- Remote.keyPossibilities key + return $ u /= Remote.uuid src && elem src remotes fromPerform :: Remote -> RemoveWhen -> Key -> AssociatedFile -> CommandPerform fromPerform src removewhen key afile = do diff --git a/doc/forum/What_is_going_on_here__63__/comment_6_536adad665f481a15d4096360d0106c1._comment b/doc/forum/What_is_going_on_here__63__/comment_6_536adad665f481a15d4096360d0106c1._comment new file mode 100644 index 0000000000..6c209adf4f --- /dev/null +++ b/doc/forum/What_is_going_on_here__63__/comment_6_536adad665f481a15d4096360d0106c1._comment @@ -0,0 +1,10 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 6""" + date="2020-12-15T18:42:30Z" + content=""" +On second thought, it can check as before and only +if the remote doesn't have the key, fall back to using information from the +log. That will be faster, and will avoid changing the behavior you were +relying on. Implemented that. +"""]]