X-Git-Url: http://git.treefish.org/~alex/photosort.git/blobdiff_plain/5b9ec26e3f502c56d73d11cafb8b411541db89d5..e0c370052ee9eb666f7ca31a26c0f3fd13e0cf2e:/src/locator.py?ds=inline diff --git a/src/locator.py b/src/locator.py index 55142c5..da74d18 100644 --- a/src/locator.py +++ b/src/locator.py @@ -10,10 +10,10 @@ class Locator: self._base_dir = base_dir self._exclude_dir = exclude_dir if not os.path.isfile(db_file): - self._conn = sqlite3.connect(db_file) + self._conn = sqlite3.connect(db_file, check_same_thread=False) self._create_db() else: - self._conn = sqlite3.connect(db_file) + self._conn = sqlite3.connect(db_file, check_same_thread=False) logging.info("Opened locator for %s.", self._base_dir) def locate_file(self, name, size, meta_time): @@ -22,15 +22,10 @@ class Locator: (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: - self._update_cache_access_time(name, size, meta_time) - return cached[0] - else: - self._remove_from_cache(name, size, meta_time) + return cached[0] else: - file_dir = misc.find_file(name, size, meta_time) + 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) @@ -61,14 +56,14 @@ class Locator: def _clean_cache(self): c = self._conn.cursor() - c.execute("DELETE FROM cache WHERE access_time