From 359ed2700cbd68627fdb5e8cd0da02b34321116a Mon Sep 17 00:00:00 2001 From: Alexander Schmidt Date: Tue, 27 Oct 2020 00:08:39 +0100 Subject: [PATCH 1/1] relax cache check --- src/locator.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/locator.py b/src/locator.py index 3b866f8..d283085 100644 --- a/src/locator.py +++ b/src/locator.py @@ -20,22 +20,25 @@ class Locator: c = self._conn.cursor() c.execute("SELECT file_dir FROM cache WHERE name=? AND size=? AND meta_time=?", (name, size, meta_time)) + cached = c.fetchone() if cached: + # if os.path.isfile(cached[0]) and \ + # os.path.getsize(cached[0]) == size and \ + # misc.extract_meta_time(cached[0]) == meta_time: if os.path.isfile(cached[0]) and \ - os.path.getsize(cached[0]) == size and \ - misc.extract_meta_time(cached[0]) == meta_time: + os.path.getsize(cached[0]) == size: self._update_cache_access_time(name, size, meta_time) return cached[0] else: self._remove_from_cache(name, size, meta_time) - else: - file_dir = misc.find_file(self._base_dir, name, size, meta_time, - self._exclude_dir) - if file_dir: - self._clean_cache() - self._add_to_cache(name, size, meta_time, file_dir) - return file_dir + + file_dir = misc.find_file(self._base_dir, name, size, meta_time, + self._exclude_dir) + if file_dir: + self._clean_cache() + self._add_to_cache(name, size, meta_time, file_dir) + return file_dir def close(self): logging.info("Closing locator for %s...", self._base_dir) -- 2.39.5