diff options
author | Kali Kaneko <kali@leap.se> | 2015-06-29 09:53:36 -0400 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2015-06-29 09:53:36 -0400 |
commit | c0f3a6afa81f93f8d1b078a62e4411b2321ba9f0 (patch) | |
tree | 72b5a9dd9b3c4ca2a42bad068d3671635b8f61c3 /src/leap/mail/adaptors/soledad.py | |
parent | cc487c6bc77769079fc4cdc23b6ad2bdd7c22394 (diff) |
[bug] avoid KeyError on pending_insert_docs lookup
in a previous commit, there was a bug inserted in which a key lookup was
being made unconditionally, even when the pending_insert_docs was None.
Releases: 0.4.0
Diffstat (limited to 'src/leap/mail/adaptors/soledad.py')
-rw-r--r-- | src/leap/mail/adaptors/soledad.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/leap/mail/adaptors/soledad.py b/src/leap/mail/adaptors/soledad.py index 0565877..4020bd0 100644 --- a/src/leap/mail/adaptors/soledad.py +++ b/src/leap/mail/adaptors/soledad.py @@ -150,7 +150,7 @@ class SoledadDocumentWrapper(models.DocumentWrapper): d.addCallback(update_doc_id) if is_copy: - d.addErrback(update_wrapper), + d.addErrback(update_wrapper) else: d.addErrback(self._catch_revision_conflict, self.future_doc_id) return d @@ -507,7 +507,7 @@ class MessageWrapper(object): for doc_id, cdoc in zip(self.mdoc.cdocs, self.cdocs.values()): cdoc.set_future_doc_id(doc_id) - def create(self, store, notify_just_mdoc=False, pending_inserts_dict=None): + def create(self, store, notify_just_mdoc=False, pending_inserts_dict={}): """ Create all the parts for this message in the store. @@ -547,13 +547,14 @@ class MessageWrapper(object): "Cannot create: fdoc has a doc_id") def unblock_pending_insert(result): - ci_headers = lowerdict(self.hdoc.headers) - msgid = ci_headers.get('message-id', None) - try: - d = pending_inserts_dict[msgid] - d.callback(msgid) - except KeyError: - pass + if pending_inserts_dict: + ci_headers = lowerdict(self.hdoc.headers) + msgid = ci_headers.get('message-id', None) + try: + d = pending_inserts_dict[msgid] + d.callback(msgid) + except KeyError: + pass return result # TODO check that the doc_ids in the mdoc are coherent |