summaryrefslogtreecommitdiff
path: root/Command/Move.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Command/Move.hs')
-rw-r--r--Command/Move.hs35
1 files changed, 28 insertions, 7 deletions
diff --git a/Command/Move.hs b/Command/Move.hs
index 787afd929..76b6c882a 100644
--- a/Command/Move.hs
+++ b/Command/Move.hs
@@ -1,6 +1,6 @@
{- git-annex command
-
- - Copyright 2010-2015 Joey Hess <id@joeyh.name>
+ - Copyright 2010-2017 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@@ -75,6 +75,9 @@ start' o move afile key ai =
Right (ToRemote dest) ->
checkFailedTransferDirection ai Upload $
toStart move afile key ai =<< getParsed dest
+ Left ToHere ->
+ checkFailedTransferDirection ai Download $
+ toHereStart move afile key ai
showMoveAction :: Bool -> Key -> ActionItem -> Annex ()
showMoveAction move = showStart' (if move then "move" else "copy")
@@ -181,14 +184,15 @@ fromOk src key = go =<< Annex.getState Annex.force
return $ u /= Remote.uuid src && elem src remotes
fromPerform :: Remote -> Bool -> Key -> AssociatedFile -> CommandPerform
-fromPerform src move key afile = ifM (inAnnex key)
- ( dispatch move True
- , dispatch move =<< go
- )
+fromPerform src move key afile = do
+ showAction $ "from " ++ Remote.name src
+ ifM (inAnnex key)
+ ( dispatch move True
+ , dispatch move =<< go
+ )
where
go = notifyTransfer Download afile $
- download (Remote.uuid src) key afile forwardRetry $ \p -> do
- showAction $ "from " ++ Remote.name src
+ download (Remote.uuid src) key afile forwardRetry $ \p ->
getViaTmp (RemoteVerify src) key $ \t ->
Remote.retrieveKeyFile src key afile t p
dispatch _ False = stop -- failed
@@ -208,3 +212,20 @@ fromPerform src move key afile = ifM (inAnnex key)
ok <- Remote.removeKey src key
next $ Command.Drop.cleanupRemote key src ok
faileddropremote = giveup "Unable to drop from remote."
+
+{- Moves (or copies) the content of an annexed file from reachable remotes
+ - to the current repository.
+ -
+ - When moving, the content is removed from all the reachable remotes. -}
+toHereStart :: Bool -> AssociatedFile -> Key -> ActionItem -> CommandStart
+toHereStart move afile key ai
+ | move = go
+ | otherwise = stopUnless (not <$> inAnnex key) go
+ where
+ go = do
+ rs <- Remote.keyPossibilities key
+ forM_ rs $ \r ->
+ includeCommandAction $ do
+ showMoveAction move key ai
+ next $ fromPerform r move key afile
+ stop