summaryrefslogtreecommitdiffstats
path: root/gallery_dl/cache.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2021-11-01 05:03:49 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2021-11-01 05:03:49 -0400
commit4a965d875415907cc1a016b428ae305a964f9228 (patch)
tree7cece9948a7ba390348e00c669f9cb1f7a9ba39a /gallery_dl/cache.py
parent34ba2951b8c523713425c98addb9256ea05c946f (diff)
New upstream version 1.19.1.upstream/1.19.1
Diffstat (limited to 'gallery_dl/cache.py')
-rw-r--r--gallery_dl/cache.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/gallery_dl/cache.py b/gallery_dl/cache.py
index 7a49b61..923ed32 100644
--- a/gallery_dl/cache.py
+++ b/gallery_dl/cache.py
@@ -211,13 +211,18 @@ def _path():
return os.path.join(cachedir, "cache.sqlite3")
-try:
- dbfile = _path()
+def _init():
+ try:
+ dbfile = _path()
+
+ # restrict access permissions for new db files
+ os.close(os.open(dbfile, os.O_CREAT | os.O_RDONLY, 0o600))
+
+ DatabaseCacheDecorator.db = sqlite3.connect(
+ dbfile, timeout=60, check_same_thread=False)
+ except (OSError, TypeError, sqlite3.OperationalError):
+ global cache
+ cache = memcache
- # restrict access permissions for new db files
- os.close(os.open(dbfile, os.O_CREAT | os.O_RDONLY, 0o600))
- DatabaseCacheDecorator.db = sqlite3.connect(
- dbfile, timeout=60, check_same_thread=False)
-except (OSError, TypeError, sqlite3.OperationalError):
- cache = memcache # noqa: F811
+_init()