codestream icon indicating copy to clipboard operation
codestream copied to clipboard

Follow Freedesktop's XDG base directory specification

Open ItsDrike opened this issue 2 years ago • 1 comments

On Linux systems, your extension is creating a folder .codestream in users $HOME directory. This clutters the home directory for no reason, when there already is a well established and known standard as to where these files should go.

The XDG Base Directory spec specifies that all configuration files belong into $XDG_CONFIG_HOME, which if not set, should default to ~/.config, rather than $HOME. Alternatively, there's also $XDG_CACHE_HOME (or by default ~/.cache) and $XDG_DATA_HOME (default: ~/.local/share).

You can simply make a codestream folder in one of these directories (or in multiple of them) rather than cuttering the home directory for absolutely no reason and not following a well established specification.

Which locations should be used and when

I've only found mappings.json in this directory, however I haven't looked in-depth into whether more files can be made there.

The rule of thumb is that

  • $XDG_CONFIG_HOME is here to hold static data that isn't expected to change very often. This is usually for user-defined configuration or things like storing credentials. These files may be accessed often, but writing into them should be rare, they're usually set once and not really touched again, unless the user wants to change their config settings.
  • $XDG_DATA_HOME should hold data that may be changing relatively often, things like databases, or perhaps even those JSON files.
  • XDG_CACHE_HOME should only be used for holding files that don't need to be backed up and loosing these files wouldn't cause any significant issues. It is expected that if the files in this location are lost, it wouldn't affect the program in any way and they should simply be regenerated cleanly. While this folder isn't automatically cleaned like temporary files would be, the user may clean them at any time and this shouldn't cause issues.
  • There are some other locations too, but they're not used that commonly, they're mentioned in the specification linked above, most notably, these are: $XDG_STATE_HOME and $XDG_RUNTIME_DIR

VSCode specifications?

I'm not very familiar with where vscode extensions should be storing the data, but there likely is a directory to hold these files as I didn't see any other extensions put their files into some other directories, perhaps you should use the folder structure that vscode already offers and store the files there. I have found this stack overflow question about this.

You could probably even utilize the ~/.vscode/extensions and keep the data in your extension folder, again, I'm not entirely familiar with where these extension data should be stored, but it's certainly not in user's $HOME directories.

ItsDrike avatar Aug 20 '21 19:08 ItsDrike

Thanks for the feedback on this @ItsDrike!

planteater avatar Aug 23 '21 22:08 planteater