summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Command/AddUrl.hs49
-rw-r--r--debian/changelog5
-rw-r--r--doc/bugs/Uses_suggested_by_CHECKURL-CONTENTS_filename_instead_of_explicitly_specified_one_in_addurl_--file_.mdwn1
3 files changed, 36 insertions, 19 deletions
diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs
index f8a4ca59b..ab6b9b8df 100644
--- a/Command/AddUrl.hs
+++ b/Command/AddUrl.hs
@@ -64,25 +64,36 @@ seek us = do
r <- Remote.claimingUrl u
if Remote.uuid r == webUUID || raw
then void $ commandAction $ startWeb relaxed optfile pathdepth u
- else do
- pathmax <- liftIO $ fileNameLengthLimit "."
- let deffile = fromMaybe (urlString2file u pathdepth pathmax) optfile
- res <- tryNonAsync $ maybe
- (error $ "unable to checkUrl of " ++ Remote.name r)
- (flip id u)
- (Remote.checkUrl r)
- case res of
- Left e -> void $ commandAction $ do
- showStart "addurl" u
- warning (show e)
- next $ next $ return False
- Right (UrlContents sz mf) -> do
- void $ commandAction $
- startRemote r relaxed (maybe deffile fromSafeFilePath mf) u sz
- Right (UrlMulti l) ->
- forM_ l $ \(u', sz, f) ->
- void $ commandAction $
- startRemote r relaxed (deffile </> fromSafeFilePath f) u' sz
+ else checkUrl r u optfile relaxed raw pathdepth
+
+checkUrl :: Remote -> URLString -> Maybe FilePath -> Bool -> Bool -> Maybe Int -> Annex ()
+checkUrl r u optfile relaxed raw pathdepth = do
+ pathmax <- liftIO $ fileNameLengthLimit "."
+ let deffile = fromMaybe (urlString2file u pathdepth pathmax) optfile
+ go deffile =<< maybe
+ (error $ "unable to checkUrl of " ++ Remote.name r)
+ (tryNonAsync . flip id u)
+ (Remote.checkUrl r)
+ where
+
+ go _ (Left e) = void $ commandAction $ do
+ showStart "addurl" u
+ warning (show e)
+ next $ next $ return False
+ go deffile (Right (UrlContents sz mf)) = do
+ let f = fromMaybe (maybe deffile fromSafeFilePath mf) optfile
+ void $ commandAction $
+ startRemote r relaxed f u sz
+ go deffile (Right (UrlMulti l))
+ | isNothing optfile =
+ forM_ l $ \(u', sz, f) ->
+ void $ commandAction $
+ startRemote r relaxed (deffile </> fromSafeFilePath f) u' sz
+ | otherwise = error $ unwords
+ [ "That url contains multiple files according to the"
+ , Remote.name r
+ , " remote; cannot add it to a single file."
+ ]
startRemote :: Remote -> Bool -> FilePath -> URLString -> Maybe Integer -> CommandStart
startRemote r relaxed file uri sz = do
diff --git a/debian/changelog b/debian/changelog
index b76823e5a..da1096e40 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,6 +13,11 @@ git-annex (5.20150328) UNRELEASED; urgency=medium
* Relax debian package dependencies to git >= 1:1.7.7.6 rather
than needing >= 1:2.0.
* test: Fix --list-tests
+ * addurl --file: When used with a special remote that claims
+ urls and checks their contents, don't override the user's provided
+ filename with filenames that the special remote suggests. Also,
+ don't allow adding the url if the special remote says it contains
+ multiple files.
-- Joey Hess <id@joeyh.name> Fri, 27 Mar 2015 16:04:43 -0400
diff --git a/doc/bugs/Uses_suggested_by_CHECKURL-CONTENTS_filename_instead_of_explicitly_specified_one_in_addurl_--file_.mdwn b/doc/bugs/Uses_suggested_by_CHECKURL-CONTENTS_filename_instead_of_explicitly_specified_one_in_addurl_--file_.mdwn
index 0db286999..3a3a0b3cd 100644
--- a/doc/bugs/Uses_suggested_by_CHECKURL-CONTENTS_filename_instead_of_explicitly_specified_one_in_addurl_--file_.mdwn
+++ b/doc/bugs/Uses_suggested_by_CHECKURL-CONTENTS_filename_instead_of_explicitly_specified_one_in_addurl_--file_.mdwn
@@ -22,3 +22,4 @@ from which I expected test2.dat get a new URL and that Filename remote spit out
5.20150327+git27-g6af24b6-1
+> [[fixed|done]] --[[Joey]]