Skip to content

Commit

Permalink
Merge tag '0.40.2' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
felliott committed Aug 8, 2018
2 parents 94fc4ac + 8e72e84 commit 70c74ba
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
ChangeLog
*********

0.40.2 (2018-08-08)
===================
- Fix: Fix download of public figshare files.

0.40.1 (2018-07-25)
===================
- Feature: Add `X-CSRFToken` to list of acceptable CORS headers.
Expand Down
2 changes: 1 addition & 1 deletion tests/providers/figshare/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ async def test_article_download_404(self, article_provider, root_provider_fixtur
with pytest.raises(exceptions.DownloadError) as e:
await article_provider.download(path)

assert e.value.code == 403
assert e.value.code == 404
assert e.value.message == 'Download not available'

@pytest.mark.asyncio
Expand Down
16 changes: 14 additions & 2 deletions waterbutler/providers/figshare/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from typing import Tuple
from http import HTTPStatus

import aiohttp

from waterbutler.core.streams import CutoffStream
from waterbutler.core import exceptions, provider, streams

Expand Down Expand Up @@ -190,10 +192,20 @@ async def download(self, path: FigsharePath, # type: ignore
download_url,
range=range,
params=params,
allow_redirects=False,
)
if resp.status == 404:

if resp.status >= 400:
await resp.release()
raise exceptions.DownloadError('Download not available', code=HTTPStatus.FORBIDDEN)
raise exceptions.DownloadError('Download not available', code=resp.status)

if resp.status in (302, 301):
await resp.release()
if range:
resp = await aiohttp.request('GET', resp.headers['location'],
headers={'Range': self._build_range_header(range)})
else:
resp = await aiohttp.request('GET', resp.headers['location'])

return streams.ResponseStreamReader(resp)

Expand Down
2 changes: 1 addition & 1 deletion waterbutler/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.40.1'
__version__ = '0.40.2'

0 comments on commit 70c74ba

Please sign in to comment.