From 18e4ffe5562be61efe9cd206494b9853e063a897 Mon Sep 17 00:00:00 2001 From: drebs Date: Fri, 5 Aug 2016 12:34:13 -0300 Subject: [bug] create gen document after saving the actual document in couch If we create the gen document before saving the actual document in couch, we may run into problems if more than one client is syncing and trying to save documents with the same id at the same time. By moving the gen document creation to after the actual document save in couch, we rely on couch/u1db resolution of conflicts before actually allocating a new generation, and the problem above doesn't occur. --- common/src/leap/soledad/common/couch/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common/src/leap/soledad') diff --git a/common/src/leap/soledad/common/couch/__init__.py b/common/src/leap/soledad/common/couch/__init__.py index 06c94c27..be30210c 100644 --- a/common/src/leap/soledad/common/couch/__init__.py +++ b/common/src/leap/soledad/common/couch/__init__.py @@ -751,8 +751,6 @@ class CouchDatabase(object): } parts.append(conflicts) - self._allocate_new_generation(doc.doc_id, transaction_id) - # build the couch document couch_doc = { '_id': doc.doc_id, @@ -802,6 +800,8 @@ class CouchDatabase(object): last_gen, last_trans_id = self.batch_generation self.batch_generation = (last_gen + 1, transaction_id) + self._allocate_new_generation(doc.doc_id, transaction_id) + def _new_resource(self, *path): """ Return a new resource for accessing a couch database. -- cgit v1.2.3