summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2015-01-27 15:20:27 -0400
committerKali Kaneko <kali@leap.se>2015-02-11 14:05:44 -0400
commitfdbc6a7a448ca5f329bb452dc4517bd6be8804b4 (patch)
treea868d315708d3250d045548493ebe22b2f3c6cd8 /src
parent3e723f7a003f72a33d761874e64cbce0604d37a9 (diff)
ignore revisionconflicts on puts.
we surely already have that part.
Diffstat (limited to 'src')
-rw-r--r--src/leap/mail/adaptors/soledad.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/leap/mail/adaptors/soledad.py b/src/leap/mail/adaptors/soledad.py
index 721f25e..470562d 100644
--- a/src/leap/mail/adaptors/soledad.py
+++ b/src/leap/mail/adaptors/soledad.py
@@ -18,12 +18,14 @@ Soledadad MailAdaptor module.
"""
import logging
import re
+
from collections import defaultdict
from email import message_from_string
from pycryptopp.hash import sha256
from twisted.internet import defer
from zope.interface import implements
+import u1db
from leap.common.check import leap_assert, leap_assert_type
@@ -40,6 +42,8 @@ from leap.mail.interfaces import IMailAdaptor, IMessageWrapper
from leap.soledad.common.document import SoledadDocument
+logger = logging.getLogger(__name__)
+
# TODO
# [ ] Convenience function to create mail specifying subject, date, etc?
@@ -151,12 +155,24 @@ class SoledadDocumentWrapper(models.DocumentWrapper):
def update_and_put_doc(doc):
doc.content.update(self.serialize())
- return store.put_doc(doc)
+ d = store.put_doc(doc)
+ d.addErrback(self._catch_revision_conflict, doc.doc_id)
+ return d
d = store.get_doc(self._doc_id)
d.addCallback(update_and_put_doc)
return d
+ def _catch_revision_conflict(self, failure, doc_id):
+ # XXX We can have some RevisionConflicts if we try
+ # to put the docs that are already there.
+ # This can happen right now when creating/saving the cdocs
+ # during a copy. Instead of catching and ignoring this
+ # error, we should mark them in the copy so there is no attempt to
+ # create/update them.
+ failure.trap(u1db.errors.RevisionConflict)
+ logger.debug("Got conflict while putting %s" % doc_id)
+
def delete(self, store):
"""
Delete the documents for this wrapper.