From ce1cdbc0bb069d06a3acc7dbe3767dce47711c39 Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Sun, 25 Dec 2011 13:12:33 +0000 Subject: return values for Account.store_mail this also fixes the issue of not using the created msg object, cf. issue #198 --- alot/account.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'alot') diff --git a/alot/account.py b/alot/account.py index 71398c22..218e33cf 100644 --- a/alot/account.py +++ b/alot/account.py @@ -95,16 +95,22 @@ class Account(object): :type mail: :class:`email.message.Message` or str :param tags: if given, add the mail to the notmuch index and tag it :type tags: list of str + :returns: True iff mail was successfully stored + :rtype: bool """ - mbx.lock() - if isinstance(mbx, mailbox.Maildir): - msg = mailbox.MaildirMessage(mail) - msg.set_flags('S') + if not isinstance(mbx, mailbox.Mailbox): + return False else: - msg = mailbox.Message(mail) - message_id = mbx.add(mail) - mbx.flush() - mbx.unlock() + mbx.lock() + if isinstance(mbx, mailbox.Maildir): + msg = mailbox.MaildirMessage(mail) + msg.set_flags('S') + else: + msg = mailbox.Message(mail) + mbx.add(msg) + mbx.flush() + mbx.unlock() + return True if isinstance(mbx, mailbox.Maildir) and tags != None: # this is a dirty hack to get the path to the newly added file -- cgit v1.2.3