-
Notifications
You must be signed in to change notification settings - Fork 53
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
Attempt to use user configured dirs for caching #153
Conversation
33d2eba
to
dd8374e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not going to be a problem with this review, but cli/cli
has some hardcoded references to the legacy cache location
if a := os.Getenv(xdgCacheHome); a != "" { | ||
return filepath.Join(a, "gh") | ||
} else if b := os.Getenv(localAppData); runtime.GOOS == "windows" && b != "" { | ||
return filepath.Join(b, "GitHub CLI") | ||
} else if c, err := os.UserHomeDir(); err == nil { | ||
return filepath.Join(c, ".cache", "gh") | ||
} else { | ||
// Note that this has a minor security issue because /tmp is world-writeable. | ||
// As such, it is possible for other users on a shared system to overwrite cached data. | ||
// The practical risk of this is low, but it's worth calling out as a risk. | ||
// I've included this here for backwards compatibility but we should consider removing it. | ||
return filepath.Join(os.TempDir(), "gh-cli-cache") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there is a problem, but I was wondering how cli/cli
would handle this directory if it didn't exist because someone deleted it manually or used gh config clear-cache
but I realized that would be an issue regardless where the directory was.
Co-authored-by: Andy Feller <[email protected]>
Excellent call out. Let's make sure we resolve that when we bump! |
Description
This change supports
XDG_CACHE_DIR
from the xdg spec.A minor concern I have about moving this out of
/tmp
is that we might slowly fill up the disk. In practice I'm not sure that this is a big issue.