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.
This commit is contained in:
parent
f842888de3
commit
6b55974723
3 changed files with 36 additions and 19 deletions
|
@ -64,25 +64,36 @@ seek us = do
|
||||||
r <- Remote.claimingUrl u
|
r <- Remote.claimingUrl u
|
||||||
if Remote.uuid r == webUUID || raw
|
if Remote.uuid r == webUUID || raw
|
||||||
then void $ commandAction $ startWeb relaxed optfile pathdepth u
|
then void $ commandAction $ startWeb relaxed optfile pathdepth u
|
||||||
else do
|
else checkUrl r u optfile relaxed raw pathdepth
|
||||||
pathmax <- liftIO $ fileNameLengthLimit "."
|
|
||||||
let deffile = fromMaybe (urlString2file u pathdepth pathmax) optfile
|
checkUrl :: Remote -> URLString -> Maybe FilePath -> Bool -> Bool -> Maybe Int -> Annex ()
|
||||||
res <- tryNonAsync $ maybe
|
checkUrl r u optfile relaxed raw pathdepth = do
|
||||||
(error $ "unable to checkUrl of " ++ Remote.name r)
|
pathmax <- liftIO $ fileNameLengthLimit "."
|
||||||
(flip id u)
|
let deffile = fromMaybe (urlString2file u pathdepth pathmax) optfile
|
||||||
(Remote.checkUrl r)
|
go deffile =<< maybe
|
||||||
case res of
|
(error $ "unable to checkUrl of " ++ Remote.name r)
|
||||||
Left e -> void $ commandAction $ do
|
(tryNonAsync . flip id u)
|
||||||
showStart "addurl" u
|
(Remote.checkUrl r)
|
||||||
warning (show e)
|
where
|
||||||
next $ next $ return False
|
|
||||||
Right (UrlContents sz mf) -> do
|
go _ (Left e) = void $ commandAction $ do
|
||||||
void $ commandAction $
|
showStart "addurl" u
|
||||||
startRemote r relaxed (maybe deffile fromSafeFilePath mf) u sz
|
warning (show e)
|
||||||
Right (UrlMulti l) ->
|
next $ next $ return False
|
||||||
forM_ l $ \(u', sz, f) ->
|
go deffile (Right (UrlContents sz mf)) = do
|
||||||
void $ commandAction $
|
let f = fromMaybe (maybe deffile fromSafeFilePath mf) optfile
|
||||||
startRemote r relaxed (deffile </> fromSafeFilePath f) u' sz
|
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 :: Remote -> Bool -> FilePath -> URLString -> Maybe Integer -> CommandStart
|
||||||
startRemote r relaxed file uri sz = do
|
startRemote r relaxed file uri sz = do
|
||||||
|
|
5
debian/changelog
vendored
5
debian/changelog
vendored
|
@ -13,6 +13,11 @@ git-annex (5.20150328) UNRELEASED; urgency=medium
|
||||||
* Relax debian package dependencies to git >= 1:1.7.7.6 rather
|
* Relax debian package dependencies to git >= 1:1.7.7.6 rather
|
||||||
than needing >= 1:2.0.
|
than needing >= 1:2.0.
|
||||||
* test: Fix --list-tests
|
* 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
|
-- Joey Hess <id@joeyh.name> Fri, 27 Mar 2015 16:04:43 -0400
|
||||||
|
|
||||||
|
|
|
@ -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
|
5.20150327+git27-g6af24b6-1
|
||||||
|
|
||||||
|
> [[fixed|done]] --[[Joey]]
|
||||||
|
|
Loading…
Add table
Reference in a new issue