diff options
author | Joey Hess <joey@kitenet.net> | 2014-04-02 15:22:39 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-04-02 15:22:39 -0400 |
commit | ba57e4ee1704747e30307aabcb1a22af892ee200 (patch) | |
tree | 799cda5f8b3015629dfc847c78dae22688ed24cf /Command | |
parent | d3d39d7cac880892241ee19092e5b53ee7e083db (diff) |
improve addurl --file behavior in a confusing corner case involving a ftp url
Diffstat (limited to 'Command')
-rw-r--r-- | Command/AddUrl.hs | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs index 1c73cd24f..b108be507 100644 --- a/Command/AddUrl.hs +++ b/Command/AddUrl.hs @@ -134,17 +134,20 @@ perform relaxed url file = ifAnnexed file addurl geturl | relaxed = do setUrlPresent key url next $ return True - | otherwise = do - (exists, samesize) <- Url.withUrlOptions $ Url.check url (keySize key) - if exists && samesize - then do - setUrlPresent key url - next $ return True - 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 + | otherwise = ifM (elem url <$> getUrls key) + ( stop + , do + (exists, samesize) <- Url.withUrlOptions $ Url.check url (keySize key) + if exists && samesize + then do + setUrlPresent key url + next $ return True + else do + warning $ "while adding a new url to an already annexed file, " ++ 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 |