diff --git a/docs/configuration.rst b/docs/configuration.rst index 819874c5..e47b2807 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -1492,7 +1492,8 @@ cache.file ---------- =========== ===== Type |Path|_ -Default |tempfile.gettempdir()|_ + ``".gallery-dl.cache"`` +Default * |tempfile.gettempdir()|_ + ``".gallery-dl.cache"`` on Windows + * (``$XDG_CACHE_HOME`` or ``"~/.cache"``) + ``".gallery-dl.cache"`` 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 25b66607..1cee4a29 100644 --- a/gallery_dl/cache.py +++ b/gallery_dl/cache.py @@ -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: diff --git a/gallery_dl/version.py b/gallery_dl/version.py index 33d19595..20797434 100644 --- a/gallery_dl/version.py +++ b/gallery_dl/version.py @@ -6,4 +6,4 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. -__version__ = "1.9.1-dev" +__version__ = "1.10.0-dev"