From 0609afd1e470dbf48cc46e24d1f8bf69c2b6731e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Thu, 1 Aug 2019 21:47:13 +0200 Subject: [PATCH] update default cache directory ... again Use a 'gallery-dl' subdirectory in ~/.cache to adhere to how other programs store their cached data, and call os.makedirs() so it also works without an existing ~/.cache directory. --- docs/configuration.rst | 2 +- gallery_dl/cache.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index e47b2807..c6f757de 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -1493,7 +1493,7 @@ cache.file =========== ===== Type |Path|_ Default * |tempfile.gettempdir()|_ + ``".gallery-dl.cache"`` on Windows - * (``$XDG_CACHE_HOME`` or ``"~/.cache"``) + ``".gallery-dl.cache"`` on all other platforms + * (``$XDG_CACHE_HOME`` or ``"~/.cache"``) + ``"/gallery-dl/cache.sqlite3"`` on all other platforms Description Path of the SQLite3 database used to cache login sessions, cookies and API tokens across `gallery-dl` invocations. diff --git a/gallery_dl/cache.py b/gallery_dl/cache.py index 1cee4a29..3ceef754 100644 --- a/gallery_dl/cache.py +++ b/gallery_dl/cache.py @@ -194,12 +194,12 @@ def _path(): if os.name == "nt": import tempfile - cachedir = tempfile.gettempdir() - else: - cachedir = util.expand_path( - os.environ.get("XDG_CACHE_HOME", "~/.cache")) + return os.path.join(tempfile.gettempdir(), ".gallery-dl.cache") - return os.path.join(cachedir, ".gallery-dl.cache") + cachedir = util.expand_path(os.path.join( + os.environ.get("XDG_CACHE_HOME", "~/.cache"), "gallery-dl")) + os.makedirs(cachedir, exist_ok=True) + return os.path.join(cachedir, "cache.sqlite3") try: