avalanchego icon indicating copy to clipboard operation
avalanchego copied to clipboard

AEP: Use XDG Base Directories for data and config

Open moreati opened this issue 5 years ago • 3 comments

AVA Enhancement Proposal

Abstract

This AEP proposes storing per-node data (e.g. the databases, staking keys) in directories according to XDG Base directory specification. For instance the staking key might be stored as follows

OS Path
Linux/BSD ~/.config/ava-labs/gecko/staking
MacOS ~/Library/Application Support/ava-labs/gecko/staking
Windows %APPDATA%\ava-labs\gecko\staking

Motivation

On unix-like operating systems there hasn't traditionally been a standard for how applications show structure data they write into a user's home directory. Typically the convention has been '~/.<application>, or ~/.<application>/some_file. This has lead to a large proliferation of such "dot files". XDG Base directory tries to provide some guidance and structure. Files can be written to different locations, based on their lifetime/purpose, these are

  • $XDG_DATA_HOME for long lived data that should be preserved (e.g. the database)
  • $XDG_CONFIG_HOME for configuration data
  • $XDG_CACHE_HOME for non-essential data that can be discarded if necessary

Proposal

The existing data store location ~/.gecko should be replaced by one or more locations that follow XDG Base directory. These might be $XDG_DATA_HOME/ava-labs/gecko/db, $XDG_CONFIG_HOME/ava-labs/gecko/staking.

Positives:

  • Using XDG Base directories advertises to third party tools what the nature of the data is. For instance a disk cleaner would know that $XDG_CONFIG_HOME/ava-labs/gecko/staking should be preserved, but that XDG_CACHE_HOME/ava-labs/gecko/* could be safely discarded.
  • $XDG_CONFIG_HOME/ava-labs/gecko' namespaces the files, making it easier to search the web, for information that concerns the contents. It reduces confusion about whether .gecko` contains files for Mozilla Gecko based web browsers.
  • Using $XDG_CONFIG_HOME reduces the proliferation of dot folder, and dot files in a user's home directory.
  • Using $XDG_CONFIG_HOME puts files in locations that are most appropriate for other platforms, rather than sprinkling Unix droppings in a Windows user home directory.

Negatives:

  • Configuration file paths would differ by OS, complicating product documentation and support
  • Migration to from the existing layout to a new layout would be required, incurring coordination and upgrade costs
  • At least one additional Go dependency would be added

Unresolved considerations

  • Does a suitable implementation exist for Go? A cursory search found https://github.com/OpenPeeDeeP/xdg, but it has not been trailed.

By submitting this issue I agree to the Terms and Conditions of the Developer Accelerator Program.

moreati avatar May 11 '20 20:05 moreati

This proposal originated as a comment on #145

moreati avatar May 11 '20 20:05 moreati