Patch for multi-response imap SELECT
Lars Thalmann
web at larsthalmann.com
Tue Jun 8 19:10:31 BST 2010
Hi,
It seems some servers (Zimbra?) respond to imap SELECT requests with
multiple EXISTS lines:
? SELECT INBOX
* 500 EXISTS
* 0 RECENT
* 1000 EXISTS
* 0 RECENT
* 1500 EXISTS
* 0 RECENT
* 1567 EXISTS
* 0 RECENT
This is a rough patch to fix offlineimap so that it handles this:
--- /usr/share/pyshared/offlineimap/folder/IMAP.py.old 2010-06-08 19:04:32.650092826 +0200
+++ /usr/share/pyshared/offlineimap/folder/IMAP.py 2010-06-08 19:53:36.030161637 +0200
@@ -126,7 +126,13 @@
try:
# Some mail servers do not return an EXISTS response if
# the folder is empty.
- maxmsgid = long(imapobj.untagged_responses['EXISTS'][0])
+ maxmsgid = 0
+ i = 0
+ l = len(imapobj.untagged_responses['EXISTS'])
+ while (i < l):
+ r = long(imapobj.untagged_responses['EXISTS'][i])
+ maxmsgid = max(r, maxmsgid)
+ i += 1
except KeyError:
return
if maxmsgid < 1:
Would be great with feedback on whether you think this is the right
solution or not.
Best wishes,
Lars
--
Lars Thalmann, www.larsthalmann.com
More information about the OfflineIMAP-project
mailing list