summaryrefslogtreecommitdiff
path: root/Command/AddUrl.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-12-09 12:23:45 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-12-09 12:23:45 -0400
commit3f5f28b48754bc91620a6354ca70afe4c61c9894 (patch)
tree6c71b52187f442ce619ffac7c672fc7f0b8f84ce /Command/AddUrl.hs
parentd64132a43ae176e8a1353d5463c5387a93da9ad7 (diff)
factor out a stopUnless
code melt for lunch
Diffstat (limited to 'Command/AddUrl.hs')
-rw-r--r--Command/AddUrl.hs21
1 files changed, 9 insertions, 12 deletions
diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs
index 945848e9f..75ca74031 100644
--- a/Command/AddUrl.hs
+++ b/Command/AddUrl.hs
@@ -45,18 +45,15 @@ download url file = do
let dummykey = Backend.URL.fromUrl url
tmp <- fromRepo $ gitAnnexTmpLocation dummykey
liftIO $ createDirectoryIfMissing True (parentDir tmp)
- ok <- liftIO $ Url.download url tmp
- if ok
- then do
- [(backend, _)] <- Backend.chooseBackends [file]
- k <- Backend.genKey tmp backend
- case k of
- Nothing -> stop
- Just (key, _) -> do
- moveAnnex key tmp
- setUrlPresent key url
- next $ Command.Add.cleanup file key True
- else stop
+ stopUnless (liftIO $ Url.download url tmp) $ do
+ [(backend, _)] <- Backend.chooseBackends [file]
+ k <- Backend.genKey tmp backend
+ case k of
+ Nothing -> stop
+ Just (key, _) -> do
+ moveAnnex key tmp
+ setUrlPresent key url
+ next $ Command.Add.cleanup file key True
nodownload :: String -> FilePath -> CommandPerform
nodownload url file = do