Shared-mime checking order

Alexander Larsson alexl at
Tue Aug 28 05:12:18 PDT 2007

On Fri, 2007-08-24 at 16:44 +0200, Alexander Larsson wrote:
> This is my main problem with hi-priority sniffing. It either causes very
> bad performance behaviour in the file manager, or it adds user-visible
> confusion as to the type of some files.
> I personally prefer to drop the hi-prio sniffing, and use sniffing only
> on conflicts and on extension match failure. This way you get only one,
> well defined, usable everywhere, canonical type (well, there is also the
> first-scan "fast mimetype", but you never open a file based on that). It
> also means that any user problem with file types is solvable by the user
> (just rename the problematic file).

Here is what I just implemented for gvfs:

If only one glob matches, use that

If no glob matches, sniff and use that

If several globs matches, and sniffing gives a result we do:
  if sniffed prio >= 80, use sniffed type
  for glob_match in glob_matches:
     if glob_match is subclass or equal to sniffed_type, use glob_match
If several globs matches, and sniffing fails, or doesn't help:
  fall back to the first glob match 
  (maybe we should do something better here?)

This algorithm only sniffs when there is some uncertainty with the
extension matching (thus, its usable for a file manager). 

Do you think this would be ok for kde to use too? Its quite similar to
what you said the kde4 file manager does already.

More information about the xdg mailing list