GNOME Bugzilla – Bug 760997
Incorrect mime type detection for file
Last modified: 2016-01-24 15:07:29 UTC
Created attachment 319565 [details] Example mime type spec 1. Install the attached mime type xml file under /usr/share/mime/packages 2. Change the mathematica section of /usr/share/mime/packages/freedesktop.org.xml to have a lower weight and priority ie.: <glob weight="30" pattern="*.nb"/> and <magic priority="30"> 3. Run update-mime-database /usr/share/mime 4. At this point, the definition in application-vnd.wolfram.nb.xml should be having priority over the one in freedesktop.org.xml for files with the extension .nb, and so the mimetype should be detected as application/vnd.wolfram.nb rather than application/mathematica 5. However: $ xdg-mime query filetype junk.nb application/mathematica $ gvfs-info junk.nb display name: junk.nb edit name: junk.nb name: junk.nb type: regular size: 4 uri: file:///home/jgu/tmp/junk.nb attributes: standard::type: 1 standard::name: junk.nb standard::display-name: junk.nb standard::edit-name: junk.nb standard::copy-name: junk.nb standard::icon: application-mathematica, x-office-document standard::content-type: application/mathematica standard::fast-content-type: application/vnd.wolfram.nb $ mimetype junk.nb junk.nb: application/vnd.wolfram.nb $ kmimetypefinder junk.nb application/vnd.wolfram.nb (accuracy 100) So, gvfs is getting it wrong. mimetype and kmimetypefinder are getting it right.
Reassigning to glib, as I think this must be a bug in the weight handling in xdgmimecache.c
here is what I am seeing after steps 1 - 3 (note that I added an explicit weight="80" to the <glob> in your example: update-mime-database gives me an error: Wrong namespace on document element in '/usr/share/mime/packages/test.xml' (should be http://www.freedesktop.org/standards/shared-mime-info) and the weight 80 glob for *.nb does not make it into /usr/share/mime/glob2 Adding the xmlns attribute on <mime-info> makes the warning go away, and the glob entry appears in /usr/share/mime/glob2 So, I don't know how mimetype and kmimetypefinder manage to use your file even though it is ignored by update-mime-database - are they processing the raw xml ? gio only uses the cache files. And after fixing the xml namespace, gvfs-info yields the expected mimetype.