jazzband / django-downloadview

Serve files with Django.
https://django-downloadview.readthedocs.io
Other
381 stars 58 forks source link

Don't compute size of virtual files before actual streaming #26

Closed benoitbryon closed 11 years ago

benoitbryon commented 11 years ago

DownloadMixin reads file size to respect IF_MODIFIED_SINCE header, but for VirtualFiles, this may trigger file generation and load it all in memory, which is bad.

When dealing with generated files, if the file has a modified_time, use it ; else suppose that the file is new, no matter its size.

benoitbryon commented 11 years ago

See also #13: there is a diffence between files that are generated and files which full content actually lives somewhere (in memory, on disk). For files that are computed as a whole, we can use the length. For files which are streamed, we can't. => Make the difference clear.

benoitbryon commented 11 years ago

See also #34. Commit 31c0a0f4b98a9e7795a561c08965e1dbfc703871 adds was_modified_since() to DownloadMixin. => VirtualDownloadView.was_modified_since() should always return True (and never check file size).

This is not a concern for VirtualFile, which should implement size property. It is a concern for VirtualDownloadView, which must not use file's size property.