diff options
author | Joey Hess <joey@kitenet.net> | 2011-12-09 12:23:45 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-12-09 12:23:45 -0400 |
commit | 3f5f28b48754bc91620a6354ca70afe4c61c9894 (patch) | |
tree | 6c71b52187f442ce619ffac7c672fc7f0b8f84ce /Command/Get.hs | |
parent | d64132a43ae176e8a1353d5463c5387a93da9ad7 (diff) |
factor out a stopUnless
code melt for lunch
Diffstat (limited to 'Command/Get.hs')
-rw-r--r-- | Command/Get.hs | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/Command/Get.hs b/Command/Get.hs index 093cd2cc5..b7023e2de 100644 --- a/Command/Get.hs +++ b/Command/Get.hs @@ -22,32 +22,24 @@ seek :: [CommandSeek] seek = [withNumCopies $ \n -> whenAnnexed $ start n] start :: Maybe Int -> FilePath -> (Key, Backend Annex) -> CommandStart -start numcopies file (key, _) = do - inannex <- inAnnex key - if inannex - then stop - else autoCopies key (<) numcopies $ do - from <- Annex.getState Annex.fromremote - case from of - Nothing -> go $ perform key - Just name -> do - -- get --from = copy --from - src <- Remote.byName name - ok <- Command.Move.fromOk src key - if ok - then go $ Command.Move.fromPerform src False key - else stop +start numcopies file (key, _) = stopUnless (not <$> inAnnex key) $ + autoCopies key (<) numcopies $ do + from <- Annex.getState Annex.fromremote + case from of + Nothing -> go $ perform key + Just name -> do + -- get --from = copy --from + src <- Remote.byName name + stopUnless (Command.Move.fromOk src key) $ + go $ Command.Move.fromPerform src False key where go a = do showStart "get" file next a perform :: Key -> CommandPerform -perform key = do - ok <- getViaTmp key (getKeyFile key) - if ok - then next $ return True -- no cleanup needed - else stop +perform key = stopUnless (getViaTmp key $ getKeyFile key) $ do + next $ return True -- no cleanup needed {- Try to find a copy of the file in one of the remotes, - and copy it to here. -} |