fix bug involving local git remote and out of date location log
authorJoey Hess <joeyh@joeyh.name>
Tue, 21 Apr 2020 16:36:58 +0000 (12:36 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 21 Apr 2020 16:36:58 +0000 (12:36 -0400)
get --from, move --from: When used with a local git remote, these used to
silently skip files that the location log thought were present on the
remote, when the remote actually no longer contained them. Since that
behavior could be surprising, now instead display a warning.

I got very confused when I encountered this behavior, since it was silently
skipping a file I needed that whereis said was on the remote.

get without --from already displayed a "unable to access these remotes"
message, which while a bit misleading in that the remote is likely
accessible, but just doesn't contain the file, at least indicated something
went wrong.

Having get --from display a warning makes it in line with get
w/o --from, so seems certianly ok. It might be there are situations where
move --from is used, on eg a whole directory, and the user only wants to
move whatever is present in the remote, and is perfectly ok with files
that are not present being skipped. So I'm less sure about the new warning
being ok there. OTOH, only local git remotes avoiding displaying a warning
in that case too, so this just brings them into line with other remotes.

(Also note that this makes it a little bit faster when dealing with a lot of
files, since it avoids a redundant stat of the file.)

CHANGELOG
Command/Move.hs
Remote/Git.hs
doc/bugs/get_behavior_when_location_log_is_out_of_date.mdwn

index 8ee3e6d2fd0a4566a4ea0baee485b39cec89d066..aec3d448377c3767879c2e7f93a6de65a31777c7 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -19,6 +19,10 @@ git-annex (8.20200331) UNRELEASED; urgency=medium
     with a large -J value.
   * Avoid running with more git check-attr and check-ignore processes than
     there are CPU cores when run with a large -J value.
+  * get --from, move --from: When used with a local git remote, these used
+    to silently skip files that the location log thought were present on the
+    remote, when the remote actually no longer contained them. Since that
+    behavior could be surprising, now instead display a warning.
 
  -- Joey Hess <id@joeyh.name>  Mon, 30 Mar 2020 15:58:34 -0400
 
index 68bc419e209edce13abd47959016215c94cd22d0..fd06ef01d37bcaa9e280e6c0951b293692a9056e 100644 (file)
@@ -187,16 +187,10 @@ fromStart removewhen afile key ai src = case removewhen of
                        fromPerform src removewhen key afile
 
 fromOk :: Remote -> Key -> Annex Bool
-fromOk src key 
-       | Remote.hasKeyCheap src =
-               either (const checklog) return =<< haskey
-       | otherwise = checklog
-  where
-       haskey = Remote.hasKey src key
-       checklog = do
-               u <- getUUID
-               remotes <- Remote.keyPossibilities key
-               return $ u /= Remote.uuid src && elem src remotes
+fromOk src key = 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
index 941a979cf661d3bec28d09cd75225ed8f99698bd..d0c6b3ce173221ebda55935058c76a81e95c7f4c 100644 (file)
@@ -527,7 +527,9 @@ copyFromRemote'' repo forcersync r st@(State connpool _ _ _ _) key file dest met
                onLocalFast st $ do
                        v <- Annex.Content.prepSendAnnex key
                        case v of
-                               Nothing -> return (False, UnVerified)
+                               Nothing -> do
+                                       warning "content is not present in remote"
+                                       return (False, UnVerified)
                                Just (object, checksuccess) -> do
                                        copier <- mkCopier hardlink st params
                                        runTransfer (Transfer Download u (fromKey id key))
index 47454b82a5af83c228726dfe3ad24d93a14aefcf..52c2d83b5b3c845ae5ec4324dddc71dff162c35a 100644 (file)
@@ -5,3 +5,5 @@ anything.
 (This happened with a git remote on a drive fwiw). 
 
 --[[Joey]]
+
+> [[fixed|done]] --[[Joey]]