Repository navigation
Attempt to use user configured dirs for caching - #153
Merged
Merged
Conversation
williammartin
force-pushed
the
wm/support-xdg-cache-home
branch
from
March 19, 2024 17:28
33d2eba to
dd8374e
Compare
andyfeller
approved these changes
Mar 19, 2024
andyfeller
left a comment
Contributor
There was a problem hiding this comment.
Not going to be a problem with this review, but cli/cli has some hardcoded references to the legacy cache location
Comment on lines
+293
to
+305
| 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") | ||
| } |
Contributor
There was a problem hiding this comment.
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]>
Member
Author
Excellent call out. Let's make sure we resolve that when we bump! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This change supports
XDG_CACHE_DIRfrom the xdg spec.A minor concern I have about moving this out of
/tmpis that we might slowly fill up the disk. In practice I'm not sure that this is a big issue.