summaryrefslogtreecommitdiff
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
parentd3d39d7cac880892241ee19092e5b53ee7e083db (diff)
improve addurl --file behavior in a confusing corner case involving a ftp url
-rw-r--r--Command/AddUrl.hs25
-rw-r--r--doc/bugs/problem_to_addurl_--file_with_ftp.mdwn1
2 files changed, 15 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
diff --git a/doc/bugs/problem_to_addurl_--file_with_ftp.mdwn b/doc/bugs/problem_to_addurl_--file_with_ftp.mdwn
index 55a38c094..99381b961 100644
--- a/doc/bugs/problem_to_addurl_--file_with_ftp.mdwn
+++ b/doc/bugs/problem_to_addurl_--file_with_ftp.mdwn
@@ -64,3 +64,4 @@ I am using current git-annex binary linux version on Fedora 19.
supported repository version: 5
upgrade supported from repository versions: 0 1 2 4
+> [[done]] --[[Joey]]