change default cache directory for unix systems

Use either $XDG_CACHE_HOME or ~/.cache (if the former isn't set)
and store potentially sensitive cookies and tokens in a user's
home directory and not in the world-readable /tmp.
This commit is contained in:
Mike Fährmann
2019-07-31 22:45:02 +02:00
parent 4b6edfbfd2
commit a8b60b2bd9
3 changed files with 11 additions and 6 deletions

View File

@@ -189,13 +189,17 @@ def clear():
def _path():
path = config.get(("cache", "file"), -1)
if path != -1:
return util.expand_path(path)
if path == -1:
if os.name == "nt":
import tempfile
import os.path
return os.path.join(tempfile.gettempdir(), ".gallery-dl.cache")
cachedir = tempfile.gettempdir()
else:
cachedir = util.expand_path(
os.environ.get("XDG_CACHE_HOME", "~/.cache"))
return util.expand_path(path)
return os.path.join(cachedir, ".gallery-dl.cache")
try: