summaryrefslogtreecommitdiff
path: root/Command/AddUrl.hs
diff options
context:
space:
mode:
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