Re: Using "user.mime_type" xattr for MIME guessing

On Thu, 2018-08-09 at 10:35 -0400, Colin Atkinson via gtk-devel-list
Hi everyone,
I'm working on a FUSE file system which makes network requests
whenever a file is read. So obviously, I would like to avoid excess
read requests to files.

The current implementation [0] of gio's MIME guessing seems to check
the file extension, and then immediately fall back on reading magic
bytes when this is not possible (i.e. files with an ambiguous or no
extension). In my situation, this can potentially lead to many
network requests any time a user opens a directory in Nautilus or a
file selection dialog.

According to the FreeDesktop specs [1], implementations may query the
user.mime_type xattr for a given file's MIME. But the current version
of glib seems not to make use of this.

Would there be any interest in a patch to add this functionality? If
so, I would be happy to work on it.

Please let me know if there's anything I've missed/misunderstood.

It's probably something interesting to add to GIO, though checking
xattrs also has a cost, especially on local disks.

Depending on what your FUSE is, you might want to consider writing a
gvfs backend instead, where the backend is responsible for providing
the mime-type/content-type (and all the other metadata), so you can use
whichever method is the most useful to you, with no added costs because
the metadata and the enumeration can be done in one go.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]