aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/cache.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2020-06-01 23:11:38 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2020-06-01 23:11:38 -0400
commite71c0d2e99f894c50b0d514729a8b44a90ce03a4 (patch)
treefc2ab19492570cf481e6efca5c42736a3c85f875 /gallery_dl/cache.py
parent40449733839d8ac9d6f44cc5942fb7623817d186 (diff)
parenta70a3246927b72f1ded37acd55ee719515441b5b (diff)
Update upstream source from tag 'upstream/1.14.0'
Update to upstream version '1.14.0' with Debian dir e10ad4f35c0e6250ed14f70c95b81b307b7b2acf
Diffstat (limited to 'gallery_dl/cache.py')
-rw-r--r--gallery_dl/cache.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/gallery_dl/cache.py b/gallery_dl/cache.py
index 6cde65d..3886091 100644
--- a/gallery_dl/cache.py
+++ b/gallery_dl/cache.py
@@ -57,7 +57,7 @@ class MemoryCacheDecorator(CacheDecorator):
value, expires = self.cache[key]
except KeyError:
expires = 0
- if expires < timestamp:
+ if expires <= timestamp:
value = self.func(*args, **kwargs)
expires = timestamp + self.maxage
self.cache[key] = value, expires
@@ -189,25 +189,26 @@ def clear():
def _path():
- path = config.get(("cache",), "file", -1)
- if path != -1:
+ path = config.get(("cache",), "file", util.SENTINEL)
+ if path is not util.SENTINEL:
return util.expand_path(path)
- if os.name == "nt":
- import tempfile
- return os.path.join(tempfile.gettempdir(), ".gallery-dl.cache")
+ if util.WINDOWS:
+ cachedir = os.environ.get("APPDATA", "~")
+ else:
+ cachedir = os.environ.get("XDG_CACHE_HOME", "~/.cache")
- cachedir = util.expand_path(os.path.join(
- os.environ.get("XDG_CACHE_HOME", "~/.cache"), "gallery-dl"))
+ cachedir = util.expand_path(os.path.join(cachedir, "gallery-dl"))
os.makedirs(cachedir, exist_ok=True)
return os.path.join(cachedir, "cache.sqlite3")
try:
dbfile = _path()
- if os.name != "nt":
- # restrict access permissions for new db files
- os.close(os.open(dbfile, os.O_CREAT | os.O_RDONLY, 0o600))
+
+ # 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=30, check_same_thread=False)
except (OSError, TypeError, sqlite3.OperationalError):