From 56bc3e95cabb85e5f23e30b453f90438c33efbb8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 15 May 2011 02:02:46 -0400 Subject: refactor some boilerplate --- Command/Move.hs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'Command/Move.hs') 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 -- cgit v1.2.3