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

.cache is an illegal location for a cache file and in conflict with the XDG standard #1021

Open
sigma67 opened this issue Aug 20, 2023 · 1 comment
Labels

Comments

@sigma67
Copy link

sigma67 commented Aug 20, 2023

Describe the bug
Spotipy stores its cache under .cache. If running from a user's home directory, this conflicts with the XDG standard.

https://github.com/spotipy-dev/spotipy/blob/d31969108d462c544f41aba4581a0d84a1e75d6f/spotipy/cache_handler.py#L67C1-L72

Your code

import platformdirs
platformdirs.user_cache_dir()
> '/home/sigma/.cache'

Expected behavior
Default location should be user_cache_dir()/spotipy, .cache-spotipy, or whatever else, just not in conflict with a standard location.

This is a one liner fix and amounts to

if username:
  ...
else:
  cache_path += '-spotipy'

A thorough solution would use platformdirs, but requires adding a dependency:

platformdirs.user_cache_dir(appname="spotipy", appauthor=False, ensure_exists=True).joinpath(".cache")

Output
see above

Environment:
any XDG compliant linux

Additional context
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

see also #712

@sijanec
Copy link

sijanec commented Sep 20, 2024

Note that also .cache is created with world read permissions, which is undesirable, as it contains secrets. Please use umask 0007 for sensitive files like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants