From e55273da750678b4aa2dd6257a5ca7d8de81c755 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 11 Oct 2013 13:05:00 -0400 Subject: url size fixes addurl: Improve message when adding url with wrong size to existing file. Before the message suggested the url didn't exist. Fixed handling of URL keys that have no recorded size. Before, if the key has no size, the url also had to not declare any size, which was unlikely and wrong, or it was taken to not exist. This probably would mostly affect keys that were added to the annex with addurl --relaxed. --- Command/AddUrl.hs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'Command/AddUrl.hs') diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs index b90297f27..27ca72d1a 100644 --- a/Command/AddUrl.hs +++ b/Command/AddUrl.hs @@ -124,14 +124,16 @@ perform relaxed url file = ifAnnexed file addurl geturl next $ return True | otherwise = do headers <- getHttpHeaders - ifM (Url.withUserAgent $ Url.check url headers $ keySize key) - ( do + (exists, samesize) <- Url.withUserAgent $ Url.check url headers $ keySize key + if exists && samesize + then do setUrlPresent key url next $ return True - , do - warning $ "failed to verify url exists: " ++ url + else do + warning $ if exists + then "url does not have expected file size (use --relaxed to bypass this check) " ++ url + else "failed to verify url exists: " ++ url stop - ) addUrlFile :: Bool -> URLString -> FilePath -> Annex Bool addUrlFile relaxed url file = do -- cgit v1.2.3