add UrlOptions sum type

This commit is contained in:
Joey Hess 2014-02-24 22:00:25 -04:00
parent fdc7200b25
commit 003fc2b7e1
Failed to extract signature
14 changed files with 78 additions and 65 deletions

View file

@ -134,8 +134,7 @@ perform relaxed url file = ifAnnexed file addurl geturl
setUrlPresent key url
next $ return True
| otherwise = do
(headers, options) <- getHttpHeadersOptions
(exists, samesize) <- Url.withUserAgent $ Url.check url headers options (keySize key)
(exists, samesize) <- Url.withUrlOptions $ Url.check url (keySize key)
if exists && samesize
then do
setUrlPresent key url
@ -192,8 +191,7 @@ download url file = do
-}
addSizeUrlKey :: URLString -> Key -> Annex Key
addSizeUrlKey url key = do
(headers, options) <- getHttpHeadersOptions
size <- snd <$> Url.withUserAgent (Url.exists url headers options)
size <- snd <$> Url.withUrlOptions (Url.exists url)
return $ key { keySize = size }
cleanup :: URLString -> FilePath -> Key -> Maybe FilePath -> Annex Bool
@ -212,10 +210,9 @@ cleanup url file key mtmp = do
nodownload :: Bool -> URLString -> FilePath -> Annex Bool
nodownload relaxed url file = do
(headers, options) <- getHttpHeadersOptions
(exists, size) <- if relaxed
then pure (True, Nothing)
else Url.withUserAgent $ Url.exists url headers options
else Url.withUrlOptions (Url.exists url)
if exists
then do
key <- Backend.URL.fromUrl url size