[PATCH] IMAP.cachemessagelist(): Protect against empty folders
Sebastian Spaeth
Sebastian at SSpaeth.de
Mon Sep 5 13:03:09 BST 2011
When invoked with FETCH 1:* (UID), imaplib returns [None] for empty
folders. We need to protect against this case and simply 'continue' here.
Signed-off-by: Sebastian Spaeth <Sebastian at SSpaeth.de>
---
We were not seeing this before when constructing the maxmsgid in a
complicated way (and I had failed to test this with empty folders
before)
offlineimap/folder/IMAP.py | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py
index dec14ae..d328c92 100644
--- a/offlineimap/folder/IMAP.py
+++ b/offlineimap/folder/IMAP.py
@@ -181,8 +181,10 @@ class IMAPFolder(BaseFolder):
finally:
self.imapserver.releaseconnection(imapobj)
for messagestr in response:
- # looks like: '1 (FLAGS (\\Seen Old) UID 4807)'
+ # looks like: '1 (FLAGS (\\Seen Old) UID 4807)' or None if no msg
# Discard initial message number.
+ if messagestr == None:
+ continue
messagestr = messagestr.split(' ', 1)[1]
options = imaputil.flags2hash(messagestr)
if not options.has_key('UID'):
--
1.7.4.1
More information about the OfflineIMAP-project
mailing list