summaryrefslogtreecommitdiff
path: root/Command/Move.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-05-15 02:02:46 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-05-15 02:02:46 -0400
commit56bc3e95cabb85e5f23e30b453f90438c33efbb8 (patch)
treec13ac69cfc2b5ba9582aa5c1ebd427bc0d337b16 /Command/Move.hs
parentb400984ddf9aeb24c3d67e87cfeb29470618636c (diff)
refactor some boilerplate
Diffstat (limited to 'Command/Move.hs')
-rw-r--r--Command/Move.hs22
1 files changed, 11 insertions, 11 deletions
diff --git a/Command/Move.hs b/Command/Move.hs
index 476bf866a..623003e47 100644
--- a/Command/Move.hs
+++ b/Command/Move.hs
@@ -73,10 +73,10 @@ toStart dest move file = isAnnexed file $ \(key, _) -> do
u <- getUUID g
ishere <- inAnnex key
if not ishere || u == Remote.uuid dest
- then return Nothing -- not here, so nothing to do
+ then stop -- not here, so nothing to do
else do
showAction move file
- return $ Just $ toPerform dest move key
+ next $ toPerform dest move key
toPerform :: Remote.Remote Annex -> Bool -> Key -> CommandPerform
toPerform dest move key = do
-- Checking the remote is expensive, so not done in the start step.
@@ -92,14 +92,14 @@ toPerform dest move key = do
case isthere of
Left err -> do
showNote $ show err
- return Nothing
+ stop
Right False -> do
showNote $ "to " ++ Remote.name dest ++ "..."
ok <- Remote.storeKey dest key
if ok
- then return $ Just $ toCleanup dest move key
- else return Nothing -- failed
- Right True -> return $ Just $ toCleanup dest move key
+ then next $ toCleanup dest move key
+ else stop -- failed
+ Right True -> next $ toCleanup dest move key
toCleanup :: Remote.Remote Annex -> Bool -> Key -> CommandCleanup
toCleanup dest move key = do
remoteHasKey dest key True
@@ -119,21 +119,21 @@ fromStart src move file = isAnnexed file $ \(key, _) -> do
u <- getUUID g
(remotes, _) <- Remote.keyPossibilities key
if (u == Remote.uuid src) || (null $ filter (== src) remotes)
- then return Nothing
+ then stop
else do
showAction move file
- return $ Just $ fromPerform src move key
+ next $ fromPerform src move key
fromPerform :: Remote.Remote Annex -> Bool -> Key -> CommandPerform
fromPerform src move key = do
ishere <- inAnnex key
if ishere
- then return $ Just $ fromCleanup src move key
+ then next $ fromCleanup src move key
else do
showNote $ "from " ++ Remote.name src ++ "..."
ok <- getViaTmp key $ Remote.retrieveKeyFile src key
if ok
- then return $ Just $ fromCleanup src move key
- else return Nothing -- fail
+ then next $ fromCleanup src move key
+ else stop -- fail
fromCleanup :: Remote.Remote Annex -> Bool -> Key -> CommandCleanup
fromCleanup src True key = do
ok <- Remote.removeKey src key