mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-20 20:09:07 +00:00
Use XDG_CACHE_HOME for cache
This commit is contained in:
parent
4a48108c69
commit
8f25c95f06
@ -185,7 +185,18 @@ def cache(*depends_on):
|
||||
if cache.disabled:
|
||||
return fn(*args, **kwargs)
|
||||
|
||||
cache_path = settings.user_dir.joinpath('.thefuck-cache').as_posix()
|
||||
default_xdg_cache_dir = os.path.expanduser("~/.cache")
|
||||
cache_dir = os.getenv("XDG_CACHE_HOME", default_xdg_cache_dir)
|
||||
cache_path = Path(cache_dir).joinpath('thefuck').as_posix()
|
||||
|
||||
# Ensure the cache_path exists, Python 2 does not have the exist_ok
|
||||
# parameter
|
||||
try:
|
||||
os.makedirs(cache_dir)
|
||||
except OSError:
|
||||
if not os.path.isdir(cache_dir):
|
||||
raise
|
||||
|
||||
# A bit obscure, but simplest way to generate unique key for
|
||||
# functions and methods in python 2 and 3:
|
||||
key = '{}.{}'.format(fn.__module__, repr(fn).split('at')[0])
|
||||
|
Loading…
x
Reference in New Issue
Block a user