diff --git a/gallery_dl/cache.py b/gallery_dl/cache.py index 19b775ef..187cef31 100644 --- a/gallery_dl/cache.py +++ b/gallery_dl/cache.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2016-2017 Mike Fährmann +# Copyright 2016-2018 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as @@ -187,12 +187,14 @@ class CacheDecorator(): return functools.partial(self.__call__, obj) def invalidate(self, key=None): - if key is None: - key = self.key - else: - key = "%s-%s" % (self.key, key) + key = "%s-%s" % (self.key, key) if key else self.key del self.cache[key] + def update(self, key, result): + key = "%s-%s" % (self.key, key) if key else self.key + expires = int(time.time() + self.maxage) + self.cache[key] = result, expires + def build_cache_decorator(*modules): if len(modules) > 1: diff --git a/gallery_dl/extractor/deviantart.py b/gallery_dl/extractor/deviantart.py index fff001f1..00c45650 100644 --- a/gallery_dl/extractor/deviantart.py +++ b/gallery_dl/extractor/deviantart.py @@ -577,8 +577,7 @@ class DeviantartAPI(): raise exception.AuthenticationError('"{} ({})"'.format( data.get("error_description"), data.get("error"))) if refresh_token: - _refresh_token_cache.invalidate(refresh_token) - _refresh_token_cache(refresh_token, data["refresh_token"]) + _refresh_token_cache.update(refresh_token, data["refresh_token"]) return "Bearer " + data["access_token"] def _call(self, endpoint, params=None, expect_error=False, public=True):