From 9805d3e7af65fcb5e92eafb9cc59f8870720ea00 Mon Sep 17 00:00:00 2001 From: Nicolas Sebrecht Date: Tue, 7 Nov 2017 15:07:26 +0100 Subject: [PATCH] no UIDPLUS: improve logging on failures When there is not UIDPLUS we have to figure the UID by our means. When this process fails, we don't know if the email was successfully uploaded. This patch provides better logs to explain what happened. Signed-off-by: Nicolas Sebrecht --- offlineimap/folder/IMAP.py | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py index 49104c8..97a07c0 100644 --- a/offlineimap/folder/IMAP.py +++ b/offlineimap/folder/IMAP.py @@ -722,22 +722,32 @@ class IMAPFolder(BaseFolder): OfflineImapError.ERROR.MESSAGE) if uid == 0: self.ui.warn("savemessage: Server supports UIDPLUS, but" - " we got no usable uid back. APPENDUID reponse was " + " we got no usable UID back. APPENDUID reponse was " "'%s'"% str(resp)) else: - # We don't support UIDPLUS. - uid = self.__savemessage_searchforheader(imapobj, headername, - headervalue) - # See docs for savemessage in Base.py for explanation - # of this and other return values. - if uid == 0: - self.ui.debug('imap', 'savemessage: attempt to get new UID ' - 'UID failed. Search headers manually.') - uid = self.__savemessage_fetchheaders(imapobj, headername, + try: + # We don't use UIDPLUS. + uid = self.__savemessage_searchforheader(imapobj, headername, headervalue) - self.ui.warn("savemessage: Searching mails for new " - "Message-ID failed. Could not determine new UID " - "on %s."% self.getname()) + # See docs for savemessage in Base.py for explanation + # of this and other return values. + if uid == 0: + self.ui.debug('imap', 'savemessage: attempt to get new UID ' + 'UID failed. Search headers manually.') + uid = self.__savemessage_fetchheaders(imapobj, headername, + headervalue) + self.ui.warn("savemessage: Searching mails for new " + "Message-ID failed. Could not determine new UID " + "on %s."% self.getname()) + # Something wrong happened while trying to get the UID. Explain + # the error might be about the 'get UID' process not necesseraly + # the APPEND. + except Exception: + self.ui.warn("%s: could not determine the UID while we got " + "no error while appending the email with '%s: %s'"% + (self.getname(), headername, headervalue) + ) + raise finally: if imapobj: self.imapserver.releaseconnection(imapobj)