Opening non-text files still causes contents of file to be fetched
Bug #588337 reported by
David Coles
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
IVLE |
Fix Released
|
Low
|
David Coles |
Bug Description
Opening any non-text file will still request the files contents even though it is never used. Quite bad for large media files or downloads since we effectively end up sending the file twice. Urk!
Not easy to fix unless we know the MIME type of the file before we fetch it. Current code checks the Content-Type header after it's fetched the content. Since all our mime detection is done by file extension we could probably just use the type from the JSON file listing rather than looking at the actual Content-Type of the file.
Related branches
lp:~ivle-dev/ivle/mediahandlers
- Matt Giuca: Approve
- David Coles: Approve
-
Diff: 444 lines (+202/-60)6 files modifiedivle/dispatch/request.py (+5/-0)
ivle/webapp/filesystem/browser/media/browser.css (+1/-0)
ivle/webapp/filesystem/browser/media/browser.js (+163/-33)
ivle/webapp/filesystem/browser/media/editor.js (+25/-24)
ivle/webapp/filesystem/serve/__init__.py (+1/-0)
services/serveservice (+7/-3)
Changed in ivle: | |
milestone: | none → 1.0.2 |
Changed in ivle: | |
status: | In Progress → Fix Committed |
Changed in ivle: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
I proposed a strategy for fixing this in the merge proposal for the mediahandlers branch:
1. Make handle_ contents_ response take a content_type argument, and pass listing["."].type as its value. Thus handle_ contents_ response will not look at the Content-Type of the second response, but use the type from the JSON listing in the first response (as you said above). contents_ response, make the handler for "text" actually make an AJAX call to ?return=contents to get the full contents. This makes the "text" type download the file twice... for now. But importantly it makes handle_ contents_ response no longer dependent on the supplied contents, it fetches its own. contents_ response, as it is no longer used. contents_ response.
2. In handle_
3. Delete the "response" argument to handle_
4. In handle_contents, delete the AJAX call to ?return=contents, and just directly call handle_
This would eliminate second request (for the full content) before switching on the media type. The media type is just decided by the JSON response to get the content-type, then the text media type still makes the AJAX request for the full contents. Binary would not make the full request at all (unless the user clicks to download). In the mediahandlers branch, the <img>, <audio> and <video> media would be requested only by the HTML element.