[Bugs] #4715 Sugar UNSP: sugar-toolkit-gtk3: png file get wrong mime type
Sugar Labs Bugs
bugtracker-noreply at sugarlabs.org
Thu Jan 16 14:33:31 EST 2014
#4715: sugar-toolkit-gtk3: png file get wrong mime type
---------------------------------------------+--------------------------
Reporter: godiard | Owner:
Type: defect | Status: new
Priority: Unspecified by Maintainer | Milestone: Unspecified
Component: Sugar | Version: Unspecified
Severity: Unspecified | Keywords:
Distribution/OS: Unspecified | Bug Status: Unconfirmed
---------------------------------------------+--------------------------
\
\
Reported by AU:
"When try to download a image in Browse, the option 'Keep image' save
something in the journal, but can't be opened"
In the xo or in sugar-build, if I do:
{{{
from sugar3 import mime
mime.get_for_file('/usr/share/icons/gnome/256x256/emotes/face-
surprise.png')
}}}
get 'application/octet-stream'.
Strangely in Fedora 18 (outside of sugar-build) I get 'image/png', then
probably is a regression.
{{{
Gio.content_type_guess('/usr/share/icons/gnome/256x256/emotes/face-
surprise.png', None)[0]
}}}
returns 'image/png' always.
We are using the two methods to identificate the mime type in sugar and in
sugar toolkit:
{{{
[gonzalo at localhost sugar-toolkit-gtk3]$ grep -r content_type_guess *
--include=*.py
src/sugar3/datastore/datastore.py: 'mime_type':
Gio.content_type_guess(file_path, None)[0],
src/sugar3/activity/webactivity.py: -1,
Gio.content_type_guess(path, None)[0])
src/sugar3/activity/webkit1.py: -1,
Gio.content_type_guess(path, None)[0])
src/sugar3/bundle/helpers.py: mime_type, certainty =
Gio.content_type_guess(path, data=None)
[gonzalo at localhost sugar-toolkit-gtk3]$ cd ../sugar
[gonzalo at localhost sugar]$ grep -r content_type_guess * --include=*.py
src/jarabe/journal/model.py:
Gio.content_type_guess(filename=full_path, data=None)
src/jarabe/journal/model.py: mime_type, uncertain_result_ =
Gio.content_type_guess(filename=path,
}}}
{{{
[gonzalo at localhost sugar]$ grep -r mime.get_for_file * --include=*.py
src/jarabe/view/viewsource.py: mime_type =
mime.get_for_file(self._document_path)
src/jarabe/view/viewsource.py: mime_type =
mime.get_for_file(self._file_path)
src/jarabe/journal/palettes.py: mime_type =
mime.get_for_file(file_name)
src/jarabe/frame/clipboardmenu.py: mime_type =
mime.get_for_file(file_path)
src/jarabe/frame/clipboardmenu.py: mime_type =
mime.get_for_file(file_path)
src/jarabe/frame/clipboardmenu.py: sniffed_mime_type =
mime.get_for_file(file_path)
src/jarabe/frame/clipboardobject.py: format_ =
mime.get_for_file(path)
src/jarabe/frame/clipboard.py: mime_type =
mime.get_for_file(path)
[gonzalo at localhost sugar]$ cd -
/home/gonzalo/sugar-build/sugar-toolkit-gtk3
[gonzalo at localhost sugar-toolkit-gtk3]$ grep -r mime.get_for_file *
--include=*.py
tests/test_mime.py:
self.assertEqual(mime.get_for_file(os.path.join(data_dir, "mime.svg")),
}}}
mime.get_for_file use SugarExt.mime_get_mime_type_for_file() to recognize
the files and add a little more logic to identify text files.
Attached is a simple patch to workaround this problem, but would be good
know what is the source of the problem, and if possible unify the criteria
in the code.
\
\
\
--
Ticket URL: <http://bugs.sugarlabs.org/ticket/4715>
Sugar Labs <http://sugarlabs.org/>
Sugar Labs bug tracking system
More information about the Bugs
mailing list