Commit b94da20a authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

protect client db actions with transactions

parent 153d15b6
......@@ -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)
......
......@@ -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):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment