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:
@@ -1492,7 +1492,8 @@ cache.file
|
|||||||
----------
|
----------
|
||||||
=========== =====
|
=========== =====
|
||||||
Type |Path|_
|
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,
|
Description Path of the SQLite3 database used to cache login sessions,
|
||||||
cookies and API tokens across `gallery-dl` invocations.
|
cookies and API tokens across `gallery-dl` invocations.
|
||||||
|
|
||||||
|
|||||||
@@ -189,13 +189,17 @@ def clear():
|
|||||||
|
|
||||||
def _path():
|
def _path():
|
||||||
path = config.get(("cache", "file"), -1)
|
path = config.get(("cache", "file"), -1)
|
||||||
|
if path != -1:
|
||||||
|
return util.expand_path(path)
|
||||||
|
|
||||||
if path == -1:
|
if os.name == "nt":
|
||||||
import tempfile
|
import tempfile
|
||||||
import os.path
|
cachedir = tempfile.gettempdir()
|
||||||
return os.path.join(tempfile.gettempdir(), ".gallery-dl.cache")
|
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:
|
try:
|
||||||
|
|||||||
@@ -6,4 +6,4 @@
|
|||||||
# it under the terms of the GNU General Public License version 2 as
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
# published by the Free Software Foundation.
|
# published by the Free Software Foundation.
|
||||||
|
|
||||||
__version__ = "1.9.1-dev"
|
__version__ = "1.10.0-dev"
|
||||||
|
|||||||
Reference in New Issue
Block a user