Opened 11 years ago

Closed 11 years ago

Last modified 8 years ago

#684 closed Enhancement (fixed)

Use XDG basedir spec for configuration files

Reported by: LucaFerretti Owned by: charles
Priority: Normal Milestone: 1.20
Component: GTK+ Client Version: 1.04
Severity: Minor Keywords:
Cc:

Description

The XDG Base Directory Specification provides some common paths in user's home to store personal application configurations, or, using their own words "defines where these files should be looked for by defining one or more base directories relative to which files should be located".

Currently Transmission is using this tree:

  • $HOME/.transmission/cache/
  • $HOME/.transmission/gtk/
  • $HOME/.transmission/torrents/
  • $HOME/.transmission/stats.bench

XDG basedir spec defines:

  • $XDG_DATA_HOME (usually $HOME/.local/share/) as "the base directory relative to which user specific data files should be stored"
  • $XDG_CONFIG_HOME (usually $HOME/.config/) as "the base directory relative to which user specific configuration files should be stored"
  • $XDG_CACHE_HOME (usually $HOME/.cache/) as "the base directory relative to which user specific non-essential data files should be stored"

In order to make Transmission XDG basedir compliant, following changes should be applied (but I could be wrong about locations...)

  • mv $HOME/.transmission/cache/ $XDG_CACHE_HOME/transmission/
  • mv $HOME/.transmission/gtk/ $XDG_CONFIG_HOME/transmission/gtk/
  • mv $HOME/.transmission/torrents/ $XDG_DATA_HOME/transmission/
  • mv $HOME/.transmission/stats.bench ????

Glib provides some useful functions (since version 2.6) in order to retrieve the current location of $XDG_*_HOME directories:

PS note that the datadir spec also defines system-wide directories for system data and configuration, and glib provides g_get_system_data_dirs() and g_get_system_config_dirs() functions to retrieve them.

Change History (17)

comment:1 Changed 11 years ago by charles

  • Type changed from Bug to Enhancement
  • Version changed from 1.03 to 1.04

comment:2 Changed 11 years ago by charles

  • Severity changed from Normal to Minor

comment:3 Changed 11 years ago by charles

This is a good idea, but it'll cause a lot of headaches :)

comment:4 Changed 11 years ago by antistress

i've reported Ticket #797 which as been marked as a duplicate of this one

XDG Base Directory Specification allows efficient backup, in which you can easily choose to backup your datas and/or your configuration files for instance (see http://ploum.frimouvy.org/?184-cleaning-user-preferences-keeping-user-data ). An application could easily propose such backup for the whole system if all applications were matching these specification

Therefore, although i do agree that this bug/enhancement is not vital, it would be great for Transmission to be "FreeDesktop? XDG Base Directory Specification" compliant.

comment:5 Changed 11 years ago by charles

  • Milestone changed from None Set to 1.20
  • Status changed from new to assigned

comment:6 Changed 11 years ago by charles

  • Resolution set to fixed
  • Status changed from assigned to closed

trunk: r5517

comment:7 Changed 11 years ago by charles

  • Summary changed from Use XDG basedir spec for configuration and cache files in $HOME to Use XDG basedir spec for configuration files

comment:8 Changed 11 years ago by antistress

  • Milestone changed from 1.20 to 1.30
  • Version changed from 1.04 to 1.21

Transmission has a "fix" for that in version 1.20 (Use XDG basedir spec for configuration files) but in fact it justs places all its files in ~/.config instead of splitting them between ~/.config (for configuration files) and ~/.local/share (for data files).

The freedesktop spec ( http://www.freedesktop.org/wiki/Specifications/basedir-spec ) says that the default for $XDG_CONFIG_HOME is $HOME/.config, the default for $XDG_DATA_HOME is $HOME/.local/share. So all applications should look for those environment variables and use those default vaulues if the variables are not set.

For instance, i think that the torrent folder should be in ~/.local/share ?

comment:9 Changed 11 years ago by antistress

  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:10 Changed 11 years ago by charles

  • Milestone changed from 1.30 to None Set

don't set milestones unless you're planning on providing a patch.

comment:11 Changed 11 years ago by charles

  • Milestone changed from None Set to 1.20
  • Resolution set to fixed
  • Status changed from reopened to closed
  • Version changed from 1.21 to 1.04

After reading over the spec I have to say that I disagree with antistress' reopening of the ticket.

The intention of XDG_DATA_HOME vs XDG_CONFIG_HOME is that the former should only be written to when installing software. That way the directory is relatively constant, which makes backups easier for system administrators. By contrast, XDG_DATA_HOME is where all the frequently-changed or short-term files go.

Given the short-term nature of .torrent files, IMO they're a better fit for XDG_CONFIG_HOME. They *definitely* aren't files written once when installing software.

comment:12 Changed 11 years ago by charles

That should've read "By contrast, XDG_CONFIG_HOME is where all the frequently-changed or short-term files go," of course.

comment:13 Changed 11 years ago by antistress

  • Resolution fixed deleted
  • Status changed from closed to reopened

Could you be more precise and quote the specs please, because i didn't find that distinction reading them Specs i've read and terms "data" and "configuration files" seem to me quite clear.

As proposed by LucaFerretti? i'd say that $HOME/.transmission/torrents/ is for $XDG_DATA_HOME

Would you mind if i ask on XDG mailing list ?

comment:14 Changed 11 years ago by charles

  • Resolution set to fixed
  • Status changed from reopened to closed

antistress:

The spec would be better if it spelled out the division between XDG_CONFIG_HOME and XDG_DATA_HOME, so yes, you should raise this point with the XDG mailing list.

The XDG list's previous discussions of XDG_DATA_HOME here and here and here all run along the lines of XDG_DATA_HOME being a user-writable version of /usr/share.

To me, that implies that XDG_DATA_HOME is intended for things that go in /usr/share -- icons, desktop files, and other files that are installed once and stay there forever. The intents and constraints of /usr/share are very well-defined.

.torrent files -- which come and go in a fairly short period of time and often contain sensitive passkeys -- do not fit this description.

comment:18 Changed 8 years ago by jordan

See also this thread:

http://www.mail-archive.com/ayatana@lists.launchpad.net/msg01061.html

I think these are open questions. There are clearly multiple conflicting interpretations of what the different XDG directories are for, and I would like to see the spec clarified. I don't think that thread with Waldo and Shuttleworth shed very much light on this question.

Note: See TracTickets for help on using tickets.