Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Carry #208] Use the XDG Basedir Spec for the cache #250

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

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
@@ -34,13 +33,12 @@ func BuildCredentialsCache(awsSession *session.Session, region string, cacheDir

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
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