diff options
author | Kali Kaneko <kali@leap.se> | 2014-02-12 01:35:48 -0400 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2014-02-17 11:39:49 -0400 |
commit | 07e1b3faeb8ca6b3105f954e1dfd85ba9e43e6d8 (patch) | |
tree | cbb71de3ea5c51b8a1374c9173806ce08170ca5c /mail/src | |
parent | 88049d2556a8f673e58d2ef9e507174fa348471d (diff) |
avoid revision conflict during deletion
Diffstat (limited to 'mail/src')
-rw-r--r-- | mail/src/leap/mail/imap/soledadstore.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/mail/src/leap/mail/imap/soledadstore.py b/mail/src/leap/mail/imap/soledadstore.py index 657f21fe..3415fa8f 100644 --- a/mail/src/leap/mail/imap/soledadstore.py +++ b/mail/src/leap/mail/imap/soledadstore.py @@ -143,6 +143,7 @@ class SoledadStore(ContentDedup): """ _last_uid_lock = threading.Lock() _soledad_rw_lock = threading.Lock() + _remove_lock = threading.Lock() implements(IMessageConsumer, IMessageStore) @@ -526,7 +527,7 @@ class SoledadStore(ContentDedup): def deleted_iter(self, mbox): """ - Get an iterator for the SoledadDocuments for messages + Get an iterator for the the doc_id for SoledadDocuments for messages with \\Deleted flag for a given mailbox. :param mbox: the mailbox @@ -534,9 +535,9 @@ class SoledadStore(ContentDedup): :return: iterator through deleted message docs :rtype: iterable """ - return (doc for doc in self._soledad.get_from_index( + return [doc.doc_id for doc in self._soledad.get_from_index( fields.TYPE_MBOX_DEL_IDX, - fields.TYPE_FLAGS_VAL, mbox, '1')) + fields.TYPE_FLAGS_VAL, mbox, '1')] def remove_all_deleted(self, mbox): """ @@ -547,7 +548,13 @@ class SoledadStore(ContentDedup): :type mbox: str or unicode """ deleted = [] - for doc in self.deleted_iter(mbox): - deleted.append(doc.content[fields.UID_KEY]) - self._soledad.delete_doc(doc) + for doc_id in self.deleted_iter(mbox): + with self._remove_lock: + doc = self._soledad.get_doc(doc_id) + self._soledad.delete_doc(doc) + try: + deleted.append(doc.content[fields.UID_KEY]) + except TypeError: + # empty content + pass return deleted |