Opening non-text files still causes contents of file to be fetched

Bug #588337 reported by David Coles
6
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

David Coles (dcoles)
Changed in ivle:
milestone: none → 1.0.2
Revision history for this message
Matt Giuca (mgiuca) wrote :

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).
2. In handle_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.
3. Delete the "response" argument to handle_contents_response, as it is no longer used.
4. In handle_contents, delete the AJAX call to ?return=contents, and just directly call handle_contents_response.

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.

Revision history for this message
Matt Giuca (mgiuca) wrote :

He is apparently working on it.

Changed in ivle:
assignee: nobody → David Coles (dcoles)
status: Triaged → In Progress
David Coles (dcoles)
Changed in ivle:
status: In Progress → Fix Committed
William Grant (wgrant)
Changed in ivle:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.