summaryrefslogtreecommitdiff
path: root/Command/AddUrl.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-04-02 15:22:39 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-04-02 15:22:39 -0400
commitba57e4ee1704747e30307aabcb1a22af892ee200 (patch)
tree799cda5f8b3015629dfc847c78dae22688ed24cf /Command/AddUrl.hs
parentd3d39d7cac880892241ee19092e5b53ee7e083db (diff)
improve addurl --file behavior in a confusing corner case involving a ftp url
Diffstat (limited to 'Command/AddUrl.hs')
-rw-r--r--Command/AddUrl.hs25
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