Monday, 4 March 2013

So, I did the responsible thing and fixed appdirs

In my previous post I expressed my frustration at the way a perfectly nice and fine idea, a portable way to get the standard configuration and data directory/files, was broken for Linux and BSD, because the authors of appdirs thought the XDG standard was "subject to some interpretation".

Although I said I decided not to use appdirs, I realised that wouldn't help anyone, so I fixed the code.

During the coding phase I discovered that the authors of appdirs broke the XDG standard even more, this time, ignoring XDG_DATA_DIRS, and talking about XDG_CONFIG_DIRS. When I found this I became convinced the *nix part of the implementation was subject to continuous irony, since the comment in this newly found breakage said "Perhaps should *use* that envvar", referring to XDG_CONFIG_DIRS, but writing later in code:


Sweet, isn't it?

If you want a fixed version, you can grab it from my repository, on the linux-fixes branch:


Anonymous said...

I'd propose to patch the debian package and also fill a bug in the fedora package. Maybe this might convince upstream that linux distros now a bit more about unix.

Anonymous said...

It looks to me as though the real problem is that appdirs doesn't distinguish between "configuration" and other data as the XDG basedir spec does; however hard anyone tries, it's never going to put both sorts of file in the "right" location until it distinguishes between them.

appdirs' upstream's interpretation was closer to being right if it can be assumed that all app data is configuration; yours is right if it can be assumed that app data is *never* configuration. I don't think either of those is actually true.

The best articulation I've found of the difference between configuration and other data is that deleting configuration is an appropriate thing to do if you want to restore default settings, whereas if you delete data it's time to find out whether your last backup worked...

(For instance, in a photo management app like Shotwell, the database of all your photos and their tags/albums/etc. is "data", but the size to use for thumbnails is configuration.)

eddyp said...

Unfortunately, appdirs is not in Debian. I'll look for distributions which do have the package and send my patches to them.

eddyp said...

@Anonymous: The point you're making is moot, since there are both in appdirs and in the XDG standard the notions of configuration and data as distinct entities, so all that appdirs has to do is to report what the standard says should be config. Then it is up to the application to decide what fits into which category, which is to be expected and correct.

It's not a bright idea for libraries to take decisions for the app, restricting what the app wants to do, that is so wrong it can't even be called 'wrong'.

Also, your question is helpful, but that question is for the app to ask, not for the library to sabotage the answer.