Opened 12 years ago

Closed 12 years ago

Last modified 8 years ago

#541 closed defect (fixed)

Mime type mess with files downloaded with Browse

Reported by: sayamindu Owned by: erikos
Priority: Unspecified by Maintainer Milestone:
Component: Browse Version: 0.82.x
Severity: Blocker Keywords:
Cc: tomeu, sascha_silbe Distribution/OS: Unspecified
Bug Status: Unconfirmed

Description

Files which are normally zip files (eg: Open Document files, Epub files, etc) seem to have the extension set to application/x-zip in the datastore. Steps to reproduce

  1. Open Browse and navigate to http://feedbooks.com/book/102
  1. Download the epub file linked from that page
  1. Try to open the file from the journal (you can have a mock activity which has the mimetype for application/epub+zip registered)
  1. View the log for Journal: it contains a line which says:
WARNING root: No activity can open this object, application/x-zip.

This normally occurs when the extension of the file is truncated, which means that there is no way to distinguish the file from a normal zip file.

I have seen this occur on Sucrose 0.82, on XO OS build 767

Attachments (2)

mimetypes.xml (273 bytes) - added by sayamindu 12 years ago.
As per discussion on IRC, I also included a mimetype.xml file in my activity. It did not seem to fix the problem
browse_save_with_extension.patch (1.7 KB) - added by sayamindu 12 years ago.
This hack seems to solve the issue.

Download all attachments as: .zip

Change History (9)

Changed 12 years ago by sayamindu

As per discussion on IRC, I also included a mimetype.xml file in my activity. It did not seem to fix the problem

Changed 12 years ago by sayamindu

This hack seems to solve the issue.

comment:1 Changed 12 years ago by tomeu

  • Severity changed from Major to Blocker

comment:2 Changed 12 years ago by erikos

  • Milestone changed from Unspecified by Release Team to 0.84

comment:3 Changed 12 years ago by tomeu

Would this patch help with zip-based file types? I would prefer not discarding always the mime type sent by the server because many webapps would break that way.

diff --git a/downloadmanager.py b/downloadmanager.py
index e41d06f..69d1c8a 100644
--- a/downloadmanager.py
+++ b/downloadmanager.py
@@ -180,7 +180,8 @@ class Download:
             self.dl_jobject.metadata['progress'] = '100'
             self.dl_jobject.file_path = self._target_file.path
 
-            if self._mime_type == 'application/octet-stream':
+            if self._mime_type in ['application/octet-stream',
+                                   'application/x-zip']:
                 sniffed_mime_type = mime.get_for_file(self._target_file.path)
                 self.dl_jobject.metadata['mime_type'] = sniffed_mime_type
 

comment:4 Changed 12 years ago by tomeu

Also, you may want to add an icon and a parent mime type. From the odt file:

  <sub-class-of type="application/zip"/>
  <generic-icon name="x-office-document"/>

comment:5 Changed 12 years ago by sascha_silbe

  • Cc sascha_silbe added

comment:6 Changed 12 years ago by tomeu

  • Resolution set to fixed
  • Status changed from new to closed

comment:7 Changed 8 years ago by godiard

  • Milestone 0.84 deleted

Milestone 0.84 deleted

Note: See TracTickets for help on using tickets.