Skip to content

refactor: use XDG_CACHE_HOME for default cache directory #5083

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rilnicki
Copy link

Update the tool to determine the default cache directory using the XDG_CACHE_HOME environment variable, falling back to ~/.cache if unset. This brings the tool in line with the XDG Base Directory Specification.

Move cache-related default values into a new
database_defaults.py module to centralize configuration and improve code maintainability.

These changes improve compatibility with diverse environments and promote cleaner filesystem usage.

@rilnicki
Copy link
Author

@terriko what do you think?

@terriko
Copy link
Contributor

terriko commented May 21, 2025

This looks promising!

I've approved the tests to run, but they'll likely fail because we've got a broken cache in our CI system at the moment. While we're working on getting that fixed, some thoughts:

  • We should have a test to make sure this works
  • You're going to want to update the documentation where we mention the cache (I think we do in a few places)
  • I'm not sure this is going to handle the case where XDG_CACHE_HOME isn't set, so we might need to have it do a default there
  • We may need to be careful about how it works on Windows (path stuff is always tricky there)

@rilnicki rilnicki force-pushed the xdg-cache-support branch from db5713f to 592158e Compare May 22, 2025 07:29
@rilnicki
Copy link
Author

@terriko I rebased my branch on main and added tests for database_defaults.py which include testing the cache directory behaviour. When XDG_CACHE_HOME is not set then the default path is used ~/.cache. I also updated the MANUAL.md with Cache Directory Behavior section where it is clearly (I hope so!) explained.

@terriko
Copy link
Contributor

terriko commented May 22, 2025

Thanks! I'll get the tests running again. Our cache issue is resolved so if they don't all pass this time, do take a look to see if you need to fix something.

@rilnicki rilnicki force-pushed the xdg-cache-support branch from 592158e to 0b04605 Compare May 23, 2025 07:58
Update the tool to determine the default cache directory using the
XDG_CACHE_HOME environment variable, falling back to ~/.cache if
unset. This brings the tool in line with the XDG Base Directory
Specification.

Move cache-related default values into a new
`database_defaults.py` module to centralize configuration and improve
code maintainability.

Add a test to verify environment-sensitive cache directory behavior.
Update the MANUAL to document the new cache path logic.

These changes improve compatibility with diverse environments and
promote cleaner filesystem usage.

Signed-off-by: Rafal Ilnicki <[email protected]>
@rilnicki rilnicki force-pushed the xdg-cache-support branch from 0b04605 to e77a861 Compare May 23, 2025 08:03
@rilnicki
Copy link
Author

@terriko I forgot to run linters locally on a test file - my bad. I also fixed the tests so they will work on Windows properly. I noticed that:

Shall I do anything about these?

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.

2 participants