From 17fed709c83de69c5bdf190b80eaa875fe6c9c7e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 10 Feb 2012 19:23:23 -0400 Subject: addurl --fast: Verifies that the url can be downloaded (only getting its head), and records the size in the key. --- Command/AddUrl.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Command') diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs index 496b9f2e8..40e3a0e98 100644 --- a/Command/AddUrl.hs +++ b/Command/AddUrl.hs @@ -15,6 +15,7 @@ import qualified Backend import qualified Command.Add import qualified Annex import qualified Backend.URL +import qualified Utility.Url as Url import Annex.Content import Logs.Web import qualified Option @@ -55,7 +56,7 @@ perform url file = ifAnnexed file addurl geturl download :: String -> FilePath -> CommandPerform download url file = do showAction $ "downloading " ++ url ++ " " - let dummykey = Backend.URL.fromUrl url + let dummykey = Backend.URL.fromUrl url Nothing tmp <- fromRepo $ gitAnnexTmpLocation dummykey liftIO $ createDirectoryIfMissing True (parentDir tmp) stopUnless (downloadUrl [url] tmp) $ do @@ -70,7 +71,10 @@ download url file = do nodownload :: String -> FilePath -> CommandPerform nodownload url file = do - let key = Backend.URL.fromUrl url + (exists, size) <- liftIO $ Url.exists url + unless exists $ + error $ "unable to access url: " ++ url + let key = Backend.URL.fromUrl url size setUrlPresent key url next $ Command.Add.cleanup file key False -- cgit v1.2.3