diff --git a/django_downloadview/views/base.py b/django_downloadview/views/base.py index df20973..c01872c 100644 --- a/django_downloadview/views/base.py +++ b/django_downloadview/views/base.py @@ -102,9 +102,9 @@ def was_modified_since(self, file_instance, since): Else, fallbacks to default implementation, which uses :py:func:`django.views.static.was_modified_since`. - Django's ``was_modified_since`` function needs a datetime and a size. - It is passed ``modified_time`` and ``size`` attributes from file - wrapper. If file wrapper does not support these attributes + Django's ``was_modified_since`` function needs a datetime. + It is passed the ``modified_time`` attribute from file + wrapper. If file wrapper does not support this attribute (``AttributeError`` or ``NotImplementedError`` is raised), then the file is considered as modified and ``True`` is returned. @@ -116,12 +116,11 @@ def was_modified_since(self, file_instance, since): modification_time = calendar.timegm( file_instance.modified_time.utctimetuple() ) - size = file_instance.size except (AttributeError, NotImplementedError) as e: print("!=======!", e) return True else: - return was_modified_since(since, modification_time, size) + return was_modified_since(since, modification_time) def not_modified_response(self, *response_args, **response_kwargs): """Return :class:`django.http.HttpResponseNotModified` instance.""" diff --git a/tests/views.py b/tests/views.py index 0ac6997..e9bfa91 100644 --- a/tests/views.py +++ b/tests/views.py @@ -85,13 +85,12 @@ def test_was_modified_since_django(self): When calling file wrapper's ``was_modified_since()`` raises ``NotImplementedError`` or ``AttributeError``, :meth:`django_downloadview.views.base.DownloadMixin.was_modified_since` - tries to pass file wrapper's ``size`` and ``modified_time`` to + tries to pass file wrapper's ``modified_time`` to :func:`django.views.static import was_modified_since`. """ file_wrapper = mock.Mock() file_wrapper.was_modified_since = mock.Mock(side_effect=AttributeError) - file_wrapper.size = mock.sentinel.size file_wrapper.modified_time = datetime.now() was_modified_since_mock = mock.Mock(return_value=mock.sentinel.was_modified) mixin = views.DownloadMixin() @@ -106,7 +105,6 @@ def test_was_modified_since_django(self): was_modified_since_mock.assert_called_once_with( mock.sentinel.since, calendar.timegm(file_wrapper.modified_time.utctimetuple()), - mock.sentinel.size, ) def test_was_modified_since_fallback(self): @@ -117,7 +115,7 @@ def test_was_modified_since_fallback(self): * calling file wrapper's ``was_modified_since()`` raises ``NotImplementedError`` or ``AttributeError``; - * and accessing ``size`` and ``modified_time`` from file wrapper raises + * and accessing ``modified_time`` from file wrapper raises ``NotImplementedError`` or ``AttributeError``... ... then