From 65d4c94f07dca2961ce3953c22c1e93d368a383b Mon Sep 17 00:00:00 2001 From: Nicolas Sebrecht Date: Mon, 27 Jun 2016 15:13:03 +0200 Subject: [PATCH] don't try to copy messages with UID == 0 Output a warning so that we can dig into this. For now, the patch doesn't fix the root cause. If the server returns UID 0 as valid UID number, this must be ignored as soon as possible. Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/336 Signed-off-by: Nicolas Sebrecht --- offlineimap/folder/Base.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py index 83e1525..c35ecc2 100644 --- a/offlineimap/folder/Base.py +++ b/offlineimap/folder/Base.py @@ -857,7 +857,7 @@ class BaseFolder(object): 1) Look for messages present in self but not in statusfolder. 2) invoke copymessageto() on those which: - If dstfolder doesn't have it yet, add them to dstfolder. - - Update statusfolder + - Update statusfolder. This function checks and protects us from action in dryrun mode.""" @@ -866,16 +866,26 @@ class BaseFolder(object): threads = [] - copylist = [uid for uid in self.getmessageuidlist() if not statusfolder.uidexists(uid)] + copylist = [uid for uid in self.getmessageuidlist() + if not statusfolder.uidexists(uid)] num_to_copy = len(copylist) - if num_to_copy and self.repository.account.dryrun: - self.ui.info("[DRYRUN] Copy {0} messages from {1}[{2}] to {3}".format( - num_to_copy, self, self.repository, dstfolder.repository)) + + if num_to_copy > 0 and self.repository.account.dryrun: + self.ui.info( + "[DRYRUN] Copy {0} messages from {1}[{2}] to {3}".format( + num_to_copy, self, self.repository, dstfolder.repository) + ) return + for num, uid in enumerate(copylist): # Bail out on CTRL-C or SIGTERM. if offlineimap.accounts.Account.abort_NOW_signal.is_set(): break + + if uid == 0: + self.ui.warn("Assertion that UID != 0 failed; ignoring message.") + continue + if uid > 0 and dstfolder.uidexists(uid): # dstfolder has message with that UID already, only update status. flags = self.getmessageflags(uid)