Skip to content

Conversation

samuelkarp
Copy link
Contributor

Issue #, if available:
Fixes #205
Carries #208 (from @WhyNotHugo)

Description of changes:
Currently, for caching data, a new directory is created in the current user's home directory. This is bad practice (if all apps just dump files into the user's home, it becomes somewhat unmaintainable).

The XDG Basedir Specification covers this pretty neatly; the cache directory for all applications is configurable via the XDG_CACHE_HOME variable, and falls back to ~/.cache if unset.

The os.UserCacheDir function returns the per-platorm cache dir, since the XDG-Basedir is *nix-specific (except macOS).

This changeset makes the cache for all applications live in one single location, rather that littering the user's home.

Testing:

Manual testing covers the behavior when ~/.ecr exists and when it does not.

  • Linux
  • Windows
  • MacOS

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

samuelkarp and others added 2 commits December 22, 2020 11:00
Currently, for caching data, a new directory is created in the current
user's home directory. This is bad practice (if all apps just dump files
into the user's home, it becomes somewhat unmaintainable).

The XDG Basedir Specification covers this pretty neatly; the cache
directory for all applications is configurable via the `XDG_CACHE_HOME`
variable, and falls back to `~/.cache` if unset.

The os.UserCacheDir function returns the per-platorm cache dir, since
the XDG-Basedir is *nix-specific (except macOS).

This changeset makes the cache for all applications live in one single
location, rather that littering the user's home.

Co-authored-by: Samuel Karp <[email protected]>
@samuelkarp samuelkarp requested a review from kzys December 22, 2020 19:06
@samuelkarp samuelkarp added this to the 0.5.0 milestone Dec 22, 2020
}

if cacheDir == "" {
//Get cacheDir from env var "AWS_ECR_CACHE_DIR" or set to default
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetCacheDir does more than what this comment explains. How about removing the comment from here?

@samuelkarp samuelkarp modified the milestones: 0.5.0, 0.6.0 Feb 13, 2021
Base automatically changed from master to main February 18, 2021 20:00
@coderbirju coderbirju requested review from a team as code owners June 30, 2025 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Respect XDG Base Directory specification for cache files

2 participants