diff --git a/agkyra/agkyra/syncer/localfs_client.py b/agkyra/agkyra/syncer/localfs_client.py index 108ef2701c23644fd45b6bab78730a1e9629ac35..b1e3450d86ba549a44e1e0831d7ed0bb8fecac67 100644 --- a/agkyra/agkyra/syncer/localfs_client.py +++ b/agkyra/agkyra/syncer/localfs_client.py @@ -515,7 +515,6 @@ class LocalfsFileClient(FileClient): return {"ident": None, "info": None} def walk_filesystem(self): - db = self.get_db() candidates = {} for dirpath, dirnames, files in os.walk(self.ROOTPATH): rel_dirpath = os.path.relpath(dirpath, start=self.ROOTPATH) @@ -532,11 +531,16 @@ class LocalfsFileClient(FileClient): candidates[objname] = self.none_info() db_cands = dict((name, self.none_info()) - for name in db.list_files(self.SIGNATURE)) + for name in self.list_files()) candidates.update(db_cands) logger.info("Candidates: %s" % candidates) return candidates + @transaction() + def list_files(self): + db = self.get_db() + return db.list_files(self.SIGNATURE) + def _local_path_changes(self, name, state): local_path = utils.join_path(self.ROOTPATH, name) return local_path_changes(local_path, state) diff --git a/agkyra/agkyra/syncer/pithos_client.py b/agkyra/agkyra/syncer/pithos_client.py index 97b1c2d120132b007a5bcd3aa3c3eea6833e6bb3..9e4a8a5f796f2d1d04c81d1bc914502af6247ea4 100644 --- a/agkyra/agkyra/syncer/pithos_client.py +++ b/agkyra/agkyra/syncer/pithos_client.py @@ -285,7 +285,6 @@ class PithosFileClient(FileClient): return d.keys() def get_pithos_candidates(self, last_modified=None): - db = self.get_db() try: objects = self.endpoint.list_objects() except ClientError as e: @@ -313,7 +312,7 @@ class PithosFileClient(FileClient): else: candidates = upstream_all - non_deleted_in_db = set(db.list_non_deleted_files(self.SIGNATURE)) + non_deleted_in_db = set(self.list_non_deleted_files()) newly_deleted_names = non_deleted_in_db.difference(upstream_all_names) logger.debug("newly_deleted %s" % newly_deleted_names) newly_deleted = dict((name, {"ident": None, "info": {}}) @@ -324,6 +323,11 @@ class PithosFileClient(FileClient): (last_modified, candidates)) return candidates + @transaction() + def list_non_deleted_files(self): + db = self.get_db() + return db.list_non_deleted_files(self.SIGNATURE) + def notifier(self): interval = self.settings.pithos_list_interval class PollPithosThread(utils.StoppableThread):