X-OfflineIMAP header

Johannes Stezenbach js at sig21.net
Thu Oct 7 12:47:43 BST 2010


Hi,

even though the patch might not be applied to git
due to lack of a maintainer, below is a simple patch
which I think fixes the issue.  To test it I commented
out two lines from folder/IMAP.py:

    def savemessage_searchforheader(self, imapobj, headername, headervalue):
        #if imapobj.untagged_responses.has_key('APPENDUID'):
        #    return long(imapobj.untagged_responses['APPENDUID'][-1].split(' ')[1])

Then the UID SEARCH command is executed with my IMAP servers and
returned the desired result.

Thanks
Johannes

--- snip ---

>From 0e7e5874d62ebbde4fa468fd276c1622b526c46d Mon Sep 17 00:00:00 2001
From: Johannes Stezenbach <js at sig21.net>
Date: Thu, 7 Oct 2010 12:33:27 +0200
Subject: [PATCH] Change X-OfflineIMAP header format

Change the X-OfflineIMAP header to work around possible Exchange MAPI
table overflow problem described in
http://article.gmane.org/gmane.mail.imap.offlineimap.general/1699
(It is unknown whether this problem still exits in current
Exchange versions, but let's assume the worst.)

The X-OfflineIMAP header is neccessary with some IMAP servers to
reliably determine the UID of a new messages uploaded to the server
by using the "UID SEARCH HEADER name string" command.  Since this
command compares header name and value it is sufficient to have
a unique header value and a non-unique header name.

Note that a message can have more than one X-OfflineIMAP header if
the message was copied between IMAP folders multiple times.
---
 offlineimap/folder/IMAP.py |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py
index c90d0e5..927c5f4 100644
--- a/offlineimap/folder/IMAP.py
+++ b/offlineimap/folder/IMAP.py
@@ -220,10 +220,11 @@ class IMAPFolder(BaseFolder):
         return self.messagelist[uid]['flags']
 
     def savemessage_getnewheader(self, content):
-        headername = 'X-OfflineIMAP-%s-' % str(binascii.crc32(content)).replace('-', 'x')
-        headername += binascii.hexlify(self.repository.getname()) + '-'
-        headername += binascii.hexlify(self.getname())
-        headervalue= '%d-' % long(time.time())
+        headername = 'X-OfflineIMAP'
+        headervalue = '%s-' % str(binascii.crc32(content)).replace('-', 'x')
+        headervalue += binascii.hexlify(self.repository.getname()) + '-'
+        headervalue += binascii.hexlify(self.getname())
+        headervalue += '-%d-' % long(time.time())
         headervalue += str(self.randomgenerator.random()).replace('.', '')
         headervalue += '-v' + versionstr
         return (headername, headervalue)
-- 
1.7.1





More information about the OfflineIMAP-project mailing list