use %APPDATA%\gallery-dl for config/cache on Windows
This commit is contained in:
@@ -170,7 +170,7 @@ Configuration files for *gallery-dl* use a JSON-based file format.
|
|||||||
+--------------------------------------------+------------------------------------------+
|
+--------------------------------------------+------------------------------------------+
|
||||||
| Linux | Windows |
|
| Linux | Windows |
|
||||||
+--------------------------------------------+------------------------------------------+
|
+--------------------------------------------+------------------------------------------+
|
||||||
|* ``/etc/gallery-dl.conf`` |* |
|
|* ``/etc/gallery-dl.conf`` |* ``%APPDATA%\gallery-dl\config.json`` |
|
||||||
|* ``${HOME}/.config/gallery-dl/config.json``|* ``%USERPROFILE%\gallery-dl\config.json``|
|
|* ``${HOME}/.config/gallery-dl/config.json``|* ``%USERPROFILE%\gallery-dl\config.json``|
|
||||||
|* ``${HOME}/.gallery-dl.conf`` |* ``%USERPROFILE%\gallery-dl.conf`` |
|
|* ``${HOME}/.gallery-dl.conf`` |* ``%USERPROFILE%\gallery-dl.conf`` |
|
||||||
+--------------------------------------------+------------------------------------------+
|
+--------------------------------------------+------------------------------------------+
|
||||||
|
|||||||
@@ -1892,7 +1892,7 @@ cache.file
|
|||||||
----------
|
----------
|
||||||
=========== =====
|
=========== =====
|
||||||
Type |Path|_
|
Type |Path|_
|
||||||
Default * |tempfile.gettempdir()|__ + ``".gallery-dl.cache"`` on Windows
|
Default * (``%APPDATA%`` or ``"~"``) + ``"/gallery-dl/cache.sqlite3"`` on Windows
|
||||||
* (``$XDG_CACHE_HOME`` or ``"~/.cache"``) + ``"/gallery-dl/cache.sqlite3"`` 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,
|
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.
|
||||||
|
|||||||
@@ -194,20 +194,21 @@ def _path():
|
|||||||
return util.expand_path(path)
|
return util.expand_path(path)
|
||||||
|
|
||||||
if util.WINDOWS:
|
if util.WINDOWS:
|
||||||
import tempfile
|
cachedir = os.environ.get("APPDATA", "~")
|
||||||
return os.path.join(tempfile.gettempdir(), ".gallery-dl.cache")
|
else:
|
||||||
|
cachedir = os.environ.get("XDG_CACHE_HOME", "~/.cache")
|
||||||
|
|
||||||
cachedir = util.expand_path(os.path.join(
|
cachedir = util.expand_path(os.path.join(cachedir, "gallery-dl"))
|
||||||
os.environ.get("XDG_CACHE_HOME", "~/.cache"), "gallery-dl"))
|
|
||||||
os.makedirs(cachedir, exist_ok=True)
|
os.makedirs(cachedir, exist_ok=True)
|
||||||
return os.path.join(cachedir, "cache.sqlite3")
|
return os.path.join(cachedir, "cache.sqlite3")
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
dbfile = _path()
|
dbfile = _path()
|
||||||
if not util.WINDOWS:
|
|
||||||
# restrict access permissions for new db files
|
# restrict access permissions for new db files
|
||||||
os.close(os.open(dbfile, os.O_CREAT | os.O_RDONLY, 0o600))
|
os.close(os.open(dbfile, os.O_CREAT | os.O_RDONLY, 0o600))
|
||||||
|
|
||||||
DatabaseCacheDecorator.db = sqlite3.connect(
|
DatabaseCacheDecorator.db = sqlite3.connect(
|
||||||
dbfile, timeout=30, check_same_thread=False)
|
dbfile, timeout=30, check_same_thread=False)
|
||||||
except (OSError, TypeError, sqlite3.OperationalError):
|
except (OSError, TypeError, sqlite3.OperationalError):
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ _config = {}
|
|||||||
|
|
||||||
if util.WINDOWS:
|
if util.WINDOWS:
|
||||||
_default_configs = [
|
_default_configs = [
|
||||||
|
r"%APPDATA%\gallery-dl\config.json",
|
||||||
r"%USERPROFILE%\gallery-dl\config.json",
|
r"%USERPROFILE%\gallery-dl\config.json",
|
||||||
r"%USERPROFILE%\gallery-dl.conf",
|
r"%USERPROFILE%\gallery-dl.conf",
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user