display error when an invalid url is downloaded

download is documented as displaying an error when download fails, but
it didn't when the url was not valid at all. That leads to confusing
behavior.

Also, display the url with --debug
This commit is contained in:
Joey Hess 2018-09-25 13:38:20 -04:00
parent 92cef3051b
commit 26a02cb386
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 25 additions and 1 deletions

View file

@ -311,7 +311,10 @@ download meterupdate url file uo =
(DownloadWithCurl _, _)
| isfileurl u -> downloadfile u
| otherwise -> downloadcurl
Nothing -> return False
Nothing -> do
liftIO $ debugM "url" url
hPutStrLn stderr "download failed: invalid url"
return False
isfileurl u = uriScheme u == "file:"

View file

@ -120,3 +120,6 @@ It would be nice, before introducing versioning information as you outlined in t
[[!meta author=yoh]]
> Added an error message when download of an invalid url is attempted
> and also made the url be listed by --debug. [[done]] --[[Joey]]

View file

@ -0,0 +1,18 @@
[[!comment format=mdwn
username="joey"
subject="""comment 1"""
date="2018-09-25T17:31:36Z"
content="""
Misconfiguration:
joey@darkstar:~/tmp/ds001419>git show git-annex:remote.log | grep openneuro.org
336309c0-d7f8-430e-bd2b-4bdc61e587cb bucket=openneuro.org datacenter=US encryption=none exporttree=yes fileprefix=ds001419/ host=s3.amazonaws.com name=s3-PUBLIC partsize=1GiB port=80 public=yes publicurl=yes storageclass=STANDARD type=S3 timestamp=1537895418.565736858s
publicurl=yes means that the bucket's url is "yes".
Since constructing an URI object from that invalid url fails, the url
downloader fails early and this avoids the debug output that would normally be
shown too when downloading an url by recent versions of git-annex.
This also explains probably why whereis doesn't list any urls.
"""]]