From 8349915f538e670cd86b7327e31fd6bd87500db2 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Mon, 23 Nov 2015 11:24:40 -0300 Subject: No more 'need to create before delete' Checking for mdoc existence before trying to delete a deleted mail. --Issue #512 --- service/pixelated/adapter/mailstore/leap_mailstore.py | 4 +++- service/test/integration/test_leap_mailstore.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'service') diff --git a/service/pixelated/adapter/mailstore/leap_mailstore.py b/service/pixelated/adapter/mailstore/leap_mailstore.py index 42e065ac..4348347e 100644 --- a/service/pixelated/adapter/mailstore/leap_mailstore.py +++ b/service/pixelated/adapter/mailstore/leap_mailstore.py @@ -289,7 +289,9 @@ class LeapMailStore(MailStore): @defer.inlineCallbacks def delete_mail(self, mail_id): message = yield self._fetch_msg_from_soledad(mail_id) - yield message.get_wrapper().delete(self.soledad) + message_wrapper = message.get_wrapper() + if message_wrapper.mdoc.doc_id: + yield message_wrapper.delete(self.soledad) @defer.inlineCallbacks def get_mailbox_mail_ids(self, mailbox_name): diff --git a/service/test/integration/test_leap_mailstore.py b/service/test/integration/test_leap_mailstore.py index 9a7f94ae..f72a99be 100644 --- a/service/test/integration/test_leap_mailstore.py +++ b/service/test/integration/test_leap_mailstore.py @@ -190,3 +190,13 @@ class LeapMailStoreTest(SoledadTestBase): self.assertEqual(replying['single'], 'me@pixelated.org') self.assertEqual(replying['all']['to-field'], [u'addr1@pixelated.org', u'me@pixelated.org']) self.assertEqual(replying['all']['cc-field'], []) + + @defer.inlineCallbacks + def test_deleting_a_deleted_mail_doesnt_raise_errors(self): + InputMail.FROM_EMAIL_ADDRESS = 'me@pixelated.org' + mail = load_mail_from_file('mbox00000000') + yield self.mail_store.add_mailbox('INBOX') + mail = yield self.mail_store.add_mail('INBOX', mail.as_string()) + + yield self.mail_store.delete_mail(mail.ident) + yield self.mail_store.delete_mail(mail.ident) -- cgit v1.2.3