mirror of
https://github.com/jazzband/django-downloadview.git
synced 2026-03-16 22:40:25 +00:00
Merge pull request #204 from sevdog/fix-realdownload-check
Use safer check in RealDownloadMiddleware
This commit is contained in:
commit
71488c49c4
1 changed files with 4 additions and 8 deletions
|
|
@ -75,14 +75,10 @@ class RealDownloadMiddleware(BaseDownloadMiddleware):
|
|||
whose file attribute have either an URL or a file name.
|
||||
|
||||
"""
|
||||
if super().is_download_response(response):
|
||||
try:
|
||||
return response.file.url or response.file.name
|
||||
except AttributeError:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
return False
|
||||
return (
|
||||
super().is_download_response(response)
|
||||
and bool(getattr(response.file, 'url', None) or getattr(response.file, 'name', None))
|
||||
)
|
||||
|
||||
|
||||
class DownloadDispatcher:
|
||||
|
|
|
|||
Loading…
Reference in a new issue