summaryrefslogtreecommitdiff
path: root/common/src/leap
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2016-08-05 12:34:13 -0300
committerdrebs <drebs@leap.se>2016-08-05 12:34:13 -0300
commit18e4ffe5562be61efe9cd206494b9853e063a897 (patch)
tree4eb4639b84b0cb519fd2eb7c85ab4e783b1debcb /common/src/leap
parent9084597674130682d84cd1884c8dbd24b866096e (diff)
[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.
Diffstat (limited to 'common/src/leap')
-rw-r--r--common/src/leap/soledad/common/couch/__init__.py4
1 files changed, 2 insertions, 2 deletions
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.