Bug 31629

Summary: xdg-mime does not search mimeinfo.cache
Product: Portland Reporter: Łukasz Stelmach <stlman>
Component: xdg-utilsAssignee: Portland Bugs <portland-bugs>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: rdieter, rkfg, tuxce.net
Version: 1.0Keywords: patch
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: search mimeinfo.cache too
xdg-mime patch to lookup mimeinfo.cache in the user dir

Description Łukasz Stelmach 2010-11-15 02:57:48 UTC
Created attachment 40278 [details] [review]
search mimeinfo.cache too

xdg-mime searches only defaults.list for an application to support given mime type. The patch makes it grep mimeinfo.cache too.
Comment 1 Rex Dieter 2010-11-18 14:36:41 UTC
Why is this needed?  Isn't the cache based from defaults.list? (and are we assured the internals of the .cache will remain consistent?)
Comment 2 Łukasz Stelmach 2010-11-18 16:15:07 UTC
As far as I can tell: no. These seems to be completely independent and to too well "specified" files. The mimeinfo.cache *was* mentioned by the Desktop Entry Specification (but only until version 0.9.4) and is used by software (I find Thunar using it on my system for example). I can find only some discussions on defaults.list on freedesktop mailing lists. BTW. the mimeinfo.cache I am talking about is a text file with a similar format as defaults.list and not some binary blob like the /usr/share/mime/mime.cache.
Comment 3 Dan Muresan 2011-03-31 08:47:37 UTC
First of all, I think this patch does the right thing -- but mimeapps.list also needs to be checked. There seems to be some confusion, so I'll add some explanations.

mimeinfo.cache (both the system one and the user's one) are ENUMERATIONS of AVAILABLE handlers for each mime type. They encode no preference or PRIORITY.

User preference is encoded in defaults.list and mimeapps.list. defaults.list is older, gnome-specific, and no longer freedesktop-supported. mimeapps.list is newer, freedesktop-approved, and KDE-supported.

The "lighter" desktop environments (XFCE, LXDE) seem to still use defaults.list.

What happens when a user selects an "unusual" association? In LXDE, if I set "Open With" for text files to xpdf,

1) a new ~/.local/share/applications/xpdf-usercustom-0.desktop is created

2) ~/.local/share/applications/mimeinfo.cache and defaults.list are updated, associating text/plain to the new desktop file

Bottom line: look in defaults.list and/or mimeapps.list first, to pick the user's preferred app; then in mimeinfo.cache, to pick any available handler.
Comment 5 rkfg 2015-02-01 16:06:53 UTC
It should do the same with the user's directories. update-desktop-database regenerates ~/.local/share/applications/mimeinfo.cache and it's not being searched as of 1.1.0 rc3.
Comment 6 rkfg 2015-04-11 22:39:35 UTC
Created attachment 115022 [details] [review]
xdg-mime patch to lookup mimeinfo.cache in the user dir

Here's the patch so mimeinfo.cache of the user is used as well.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.