LucasPickering / slumber

Terminal-based HTTP/REST client
https://slumber.lucaspickering.me/
MIT License
413 stars 20 forks source link

Follow XDG Base Directory Specification for Linux #371

Closed SVendittelli closed 1 month ago

SVendittelli commented 1 month ago

Problem

On Linux, the database, log, and config files are all being stored in $XDG_DATA_HOME which doesn't follow the XDG Base Directory Specification.

Proposed solution

There is no issue with any of these files being stored in a slumber subdirectory of the following proposed locations.

The database file (state.sqlite) should be stored in the dirs::data_dir, as it currently is, no change needed.

The config file (config.yml) should be stored in dirs::config_dir. This points to the same location on macOS and Windows, so would be backwards compatible for those platforms, but would be different for Linux (i.e. $XDG_CONFIG_HOME not $XDG_DATA_HOME). This would be a breaking change.

The log file (slumber.log) is more tricky. According to the spec, this should be stored in $XDG_STATE_HOME on Linux, provided by dirs::state_dir. However, this does not have Windows and macOS equivalents in the dirs crate. For Windows and macOS, the dirs::cache_dir would be an acceptable fallback. This would be a breaking change.

Additional context

  1. XDG Base Directory Specification
  2. dirs crate
LucasPickering commented 1 month ago

Thanks for the detailed report. To be honest, I didn't put a ton of thought into the directory locations, I just pulled in dirs and ran with it. I'm happy to make this change. I have no problem moving the log files without considering it a breaking change, because I don't think anyone has any level of automation or workflows built off the log files. In fact this is the first time anyone other than me has acknowledged their existence.

For the config change, to keep it backward compatible we can just continue to check the old location, but suggest the new location in documentation/command output.

SVendittelli commented 1 month ago

That all sounds great to me, thanks for considering it.