From 21e628912726255a5fe23bd8ef59ef60fbcef002 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 13 Mar 2014 14:51:22 -0400 Subject: copy --fast --to remote: Avoid printing anything for files that are already believed to be present on the remote. --- Command/Move.hs | 40 +++++++++++++++++++++++----------------- Command/Sync.hs | 2 +- 2 files changed, 24 insertions(+), 18 deletions(-) (limited to 'Command') diff --git a/Command/Move.hs b/Command/Move.hs index af3623da0..3a39e1de0 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 07006ef28..a4004736a 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) -- cgit v1.2.3