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.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Johannes Stezenbach 2010-10-07 12:33:27 +02:00 committed by Nicolas Sebrecht
parent d687999a66
commit 573d7ed52a

View File

@ -220,10 +220,11 @@ class IMAPFolder(BaseFolder):
return self.messagelist[uid]['flags'] return self.messagelist[uid]['flags']
def savemessage_getnewheader(self, content): def savemessage_getnewheader(self, content):
headername = 'X-OfflineIMAP-%s-' % str(binascii.crc32(content)).replace('-', 'x') headername = 'X-OfflineIMAP'
headername += binascii.hexlify(self.repository.getname()) + '-' headervalue = '%s-' % str(binascii.crc32(content)).replace('-', 'x')
headername += binascii.hexlify(self.getname()) headervalue += binascii.hexlify(self.repository.getname()) + '-'
headervalue= '%d-' % long(time.time()) headervalue += binascii.hexlify(self.getname())
headervalue += '-%d-' % long(time.time())
headervalue += str(self.randomgenerator.random()).replace('.', '') headervalue += str(self.randomgenerator.random()).replace('.', '')
headervalue += '-v' + versionstr headervalue += '-v' + versionstr
return (headername, headervalue) return (headername, headervalue)