Shared-mime checking order

Alexander Larsson alexl at
Fri Jul 27 01:25:57 PDT 2007

On Mon, 2007-07-23 at 13:47 +0200, Sanel Zukan wrote:
> Hi to all,
> In shared-mime specs one of the recommended ways to check file type is
> given with:
> "if no explicit type is present, magic rules with a priority of 80 or more
> should be tried next."
> My intent is not to start discussion if proposed order is correct or wrong
> but to see how others implement cases when foo.txt is renamed to
> foo.mp3 (btw. I have to ask either, is given order for compatibility
> with older applications because seeing that file as mp3 is clearly wrong?).
> IMHO, it would be very inconsistent that, for example, EDE desktop see 
> renamed foo.txt as text/plain, but started konqueror or thunar see it as mp3
> file :-)

Gnome currently doesn't look at the priorities at all I believe. Instead
we have a hardcoded list of sniffed mimetypes[1] where we always believe
extension over mimetype. If not in this list we use the extension
mimetype if it is a subclass of the sniffed type, and the sniffed type
otherwise. However, in the last case we also warn about any mismatch and
list the apps for both types in the open with app list.

However, the warning dialog is a pain in the ass for users, and isn't
really possible for people to "fix" the issue if it gets things wrong,
so with the new gnome vfs (gvfs) we'll likely change this to use the
extension in more cases (since people can at least change that if its

Of course, we always need to sniff in a some cases anyway: 
* multiple extensions match
* no extension match

What do other desktop implementations currently do?

[1] This list is currently:
  "application/x-ole-storage", "text/xml", "application/x-bzip",
  "application/x-gzip", "application/zip"
  These are all types that many other types use as a container, like
  .dia files being gzip:ed xml files.

More information about the xdg mailing list