Subject: bug#44053: ‘xdg-mime-database’ profile hook is slow

From: Ludovic Courtès <[email-masked]>
Date: Mon, 02 Nov 2020 13:53:18 +0100

Ludovic Courtès <[email-masked]> skribis:

> Apart from LibreOffice, I found that ‘share/mime/packages’ is provided
> by at least: hugin, gcr, fontforge.  Most GUI packages don’t have it.
> So in practice, we’re often rebuilding the exact same database.

On closer inspection, the time-consuming bit is processing
‘share/mime/packages/freedesktop.org.xml’ (from ‘shared-mime-info’),
which is quite large and leads to the creation of hundreds of file.  We
end up re-processing it every time.  This is particularly wasteful
because the ‘shared-mime-info’ package already contains the result of
applying ‘update-mime-database’ to itself.

Unfortunately, AIUI,

  update-mime-database(X ∪ Y) ≠ update-mime-database(X) ∪ update-mime-database(Y)

(For example, the files
‘share/mime/{globs,magic,XMLnamespaces,subclasses,aliases,types,generic-icons,icons,treemagic,mime.cache}’
concatenate info from X and Y.)

So it would seem we cannot simply used the pre-built database from
‘shared-mime-info’ and merge it with that of the other packages, at
least not without changing ‘update-mime-database’ or re-implementing
parts of it on our side.

Ludo’.