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

feature: use cache directory in user folder if possible #213

Merged
merged 1 commit into from
Nov 12, 2020

Conversation

brycedrennan
Copy link
Collaborator

okay here is an attempt at using the xdg folder. Addresses #212

While I'm not aware of any issues with this implementation I'm wary of the last changes and their unintended consequences. Could be good to sit on this for a few days

Follows the XDG Base Directory Specification
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

Falls back to attempting to use package directory if it can't determine and XDG directory location.

Copy link
Owner

@john-kurkowski john-kurkowski left a comment

Choose a reason for hiding this comment

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

Liking this so far. Seems like a drop-in, progressive enhancement, to the permission warnings throughout the years.

tests/test_cache.py Show resolved Hide resolved
mock_version_module.version = "1.2.3"
monkeypatch.setitem(sys.modules, "tldextract._version", mock_version_module)

assert get_pkg_unique_identifier() == "3.8.1.final__myvirtualenv__f01a7b__tldextract-1.2.3"
Copy link
Owner

Choose a reason for hiding this comment

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

Magic string f01a7b?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's a md5 hash of sys.prefix. not sure a better way?

tldextract/cache.py Outdated Show resolved Hide resolved
tldextract/cache.py Outdated Show resolved Hide resolved
tldextract/cache.py Outdated Show resolved Hide resolved
Follows the XDG Base Directory Specification
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

Falls back to attempting to use package directory if it can't determine and XDG directory location.
@brycedrennan
Copy link
Collaborator Author

@john-kurkowski ready for review again

Copy link
Owner

@john-kurkowski john-kurkowski left a comment

Choose a reason for hiding this comment

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

@john-kurkowski john-kurkowski merged commit 5e3b660 into john-kurkowski:master Nov 12, 2020
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this pull request Nov 29, 2020
https://build.opensuse.org/request/show/851574
by user mia + dimstar_suse
- Update to 3.1.0:
  * Features
    + Prefer to cache in XDG cache directory in user folder,
      vs. in Python install folder
      (john-kurkowski/tldextract#213)
    + Fix `AttributeError` on `--update`
      (john-kurkowski/tldextract#215)
@brycedrennan brycedrennan deleted the xdg_cache branch July 29, 2021 15:51
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