From fb7817d0657dcffebb9a21abb6597d1b9d82dd63 Mon Sep 17 00:00:00 2001 From: Miles Wells Date: Fri, 11 Oct 2024 12:06:51 +0300 Subject: [PATCH] Handle loaded_time == None in refresh_cache --- one/api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/one/api.py b/one/api.py index d11d5820..412ee206 100644 --- a/one/api.py +++ b/one/api.py @@ -236,7 +236,8 @@ def refresh_cache(self, mode='auto'): if mode in {'local', 'remote'}: pass elif mode == 'auto': - if datetime.now() - self._cache['_meta']['loaded_time'] >= self.cache_expiry: + loaded_time = self._cache['_meta']['loaded_time'] + if not loaded_time or (datetime.now() - loaded_time >= self.cache_expiry): _logger.info('Cache expired, refreshing') self.load_cache() elif mode == 'refresh':