richardlehane / siegfried

signature-based file format identification
http://www.itforarchivists.com/siegfried
Apache License 2.0
214 stars 30 forks source link

Please add `XDG_DATA_DIRS` support #242

Closed mgorny closed 1 week ago

mgorny commented 4 months ago

If I'm not mistaken, currently Siegfried supports loading data from only one location — be it SIEGFRIED_HOME, -home or user's home directory. This is inconvenient for distribution packaging where we would like to install a system-wide copy of signature file for all users to be able to use.

Could you add support for iterating over XDG_DATA_DIRS (i.e. /usr/share) when the signature file isn't found in the home directory? I think this would combine the best of both worlds, i.e. users could still easily override the signature file by placing a new one in their home directory, and the system-installed signature file would be automatically used otherwise.

ross-spencer commented 4 months ago

Have you evaluated the work associated with this issue @mgorny? https://github.com/richardlehane/siegfried/issues/216

mgorny commented 4 months ago

I'm sorry but I don't understand the question.

ross-spencer commented 4 months ago

@mgorny that issue (https://github.com/richardlehane/siegfried/issues/216) is titled: "use the xdg base directory specification for home directory" <-- seems like it's a duplicate of this, or that something in its implementation isn't working for you?

mgorny commented 4 months ago

Unless I'm mistaken, #216 only implemented XDG_DATA_HOME (e.g. ~/.local/share), while I am talking of XDG_DATA_DIRS (e.g. /usr/local/share:/usr/share).

Basically, the program should write new files to XDG_DATA_HOME. However, when reading, it should search XDG_DATA_HOME, followed by colon-separated list of XDG_DATA_DIRS, until it finds the expected file.

From https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html:

$XDG_DATA_HOME defines the base directory relative to which user-specific data files should be stored. […]

$XDG_DATA_DIRS defines the preference-ordered set of base directories to search for data files in addition to the $XDG_DATA_HOME base directory. The directories in $XDG_DATA_DIRS should be seperated with a colon ':'.

richardlehane commented 2 weeks ago

Hi Michał, I've added functionality to search XDG_DATA_DIRS when choosing the home directory. This will be available in the next release, due in about a week. If you have a chance to test it I'd appreciate, there's a release candidate available here: https://github.com/richardlehane/siegfried/releases/tag/v1.11.1-rc4

mgorny commented 2 weeks ago

Thanks. At a first glance, it seems to work fine!