diff --git a/Command/Move.hs b/Command/Move.hs index af3623da0c..3a39e1de0d 100644 --- a/Command/Move.hs +++ b/Command/Move.hs @@ -69,20 +69,29 @@ toStart dest move afile key = do ishere <- inAnnex key if not ishere || u == Remote.uuid dest then stop -- not here, so nothing to do - else do - showMoveAction move key afile - next $ toPerform dest move key afile -toPerform :: Remote -> Bool -> Key -> AssociatedFile -> CommandPerform -toPerform dest move key afile = moveLock move key $ do - -- Checking the remote is expensive, so not done in the start step. - -- In fast mode, location tracking is assumed to be correct, - -- and an explicit check is not done, when copying. When moving, - -- it has to be done, to avoid inaverdent data loss. + else toStart' dest move afile key + +toStart' :: Remote -> Bool -> AssociatedFile -> Key -> CommandStart +toStart' dest move afile key = do fast <- Annex.getState Annex.fast - let fastcheck = fast && not move && not (Remote.hasKeyCheap dest) - isthere <- if fastcheck - then Right <$> expectedpresent - else Remote.hasKey dest key + if fast && not move && not (Remote.hasKeyCheap dest) + then ifM (expectedPresent dest key) + ( stop + , go True (pure $ Right False) + ) + else go False (Remote.hasKey dest key) + where + go fastcheck isthere = do + showMoveAction move key afile + next $ toPerform dest move key afile fastcheck =<< isthere + +expectedPresent :: Remote -> Key -> Annex Bool +expectedPresent dest key = do + remotes <- Remote.keyPossibilities key + return $ dest `elem` remotes + +toPerform :: Remote -> Bool -> Key -> AssociatedFile -> Bool -> Either String Bool -> CommandPerform +toPerform dest move key afile fastcheck isthere = moveLock move key $ case isthere of Left err -> do showNote err @@ -100,7 +109,7 @@ toPerform dest move key afile = moveLock move key $ do warning "This could have failed because --fast is enabled." stop Right True -> do - unlessM expectedpresent $ + unlessM (expectedPresent dest key) $ Remote.logStatus dest key InfoPresent finish where @@ -109,9 +118,6 @@ toPerform dest move key afile = moveLock move key $ do removeAnnex key next $ Command.Drop.cleanupLocal key | otherwise = next $ return True - expectedpresent = do - remotes <- Remote.keyPossibilities key - return $ dest `elem` remotes {- Moves (or copies) the content of an annexed file from a remote - to the current repository. diff --git a/Command/Sync.hs b/Command/Sync.hs index 07006ef287..a4004736a2 100644 --- a/Command/Sync.hs +++ b/Command/Sync.hs @@ -376,5 +376,5 @@ syncFile rs f (k, _) = do put dest = do ok <- commandAction $ do showStart "copy" f - next $ Command.Move.toPerform dest False k (Just f) + Command.Move.toStart' dest False (Just f) k return (ok, if ok then Just (Remote.uuid dest) else Nothing) diff --git a/debian/changelog b/debian/changelog index ca82d88ad7..86e0fae391 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,8 @@ git-annex (5.20140307) UNRELEASED; urgency=medium * repair: Improve memory usage when git fsck finds a great many broken objects. * webapp: Use securemem for constant time auth token comparisons. + * copy --fast --to remote: Avoid printing anything for files that + are already believed to be present on the remote. -- Joey Hess Thu, 06 Mar 2014 16:17:01 -0400 diff --git a/doc/bugs/copy_to_--fast_should_not_mention_every_file_it_checks.mdwn b/doc/bugs/copy_to_--fast_should_not_mention_every_file_it_checks.mdwn index 7c0137fb1e..81d84b300c 100644 --- a/doc/bugs/copy_to_--fast_should_not_mention_every_file_it_checks.mdwn +++ b/doc/bugs/copy_to_--fast_should_not_mention_every_file_it_checks.mdwn @@ -23,3 +23,6 @@ No information whatsoever is printed during upload when ran without `--quite` it """]] [[!meta title="copy --fast --to remote should be quiet when nothing to do"]] + +> [[fixed|done]]; Avoided the unnecessary output in this situation. +> --[[Joey]]