summaryrefslogtreecommitdiff
path: root/Command/Move.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-03-13 14:51:22 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-03-13 14:51:22 -0400
commit21e628912726255a5fe23bd8ef59ef60fbcef002 (patch)
treea58b2d9264aa19d4473cbe7cf8dd6e04eeec3f48 /Command/Move.hs
parent699b34e03f3fcdb90909b02aa4f71706b75e37b4 (diff)
copy --fast --to remote: Avoid printing anything for files that are already believed to be present on the remote.
Diffstat (limited to 'Command/Move.hs')
-rw-r--r--Command/Move.hs40
1 files changed, 23 insertions, 17 deletions
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.