diff options
| author | 2021-11-01 05:03:56 -0400 | |
|---|---|---|
| committer | 2021-11-01 05:03:56 -0400 | |
| commit | d44db4008a1bc8f83d1172935d524cc368fd3f8c (patch) | |
| tree | 1bfd7014b7d5f8875a4061059052a0039e1e9d9c /gallery_dl/cache.py | |
| parent | cdb02b484db3c399494d336a5107351a2d1d4429 (diff) | |
| parent | 4a965d875415907cc1a016b428ae305a964f9228 (diff) | |
Update upstream source from tag 'upstream/1.19.1'
Update to upstream version '1.19.1'
with Debian dir 221a69d6fa394ae5c38ce580f53cd49976cffd88
Diffstat (limited to 'gallery_dl/cache.py')
| -rw-r--r-- | gallery_dl/cache.py | 21 |
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() |
