Merge branch 'next'

This commit is contained in:
Nicolas Sebrecht 2011-08-10 21:50:03 +02:00
commit 0c0d0c0cfd
5 changed files with 34 additions and 5 deletions

View File

@ -12,6 +12,20 @@ ChangeLog
releases announces. releases announces.
OfflineIMAP v6.3.4 (2011-08-10)
===============================
Notes
-----
Here we are. A nice release since v6.3.3, I think.
Changes
-------
* Handle when UID can't be found on saved messages.
OfflineIMAP v6.3.4-rc4 (2011-07-27) OfflineIMAP v6.3.4-rc4 (2011-07-27)
=================================== ===================================

View File

@ -189,6 +189,11 @@ Then, on your next sync, the message will be re-downloaded with the proper UID.
`OfflineIMAP`_ makes sure that the message was properly uploaded before `OfflineIMAP`_ makes sure that the message was properly uploaded before
deleting it, so there should be no risk of data loss. deleting it, so there should be no risk of data loss.
But if you try to sync between two IMAP servers, where both are unable to
provide you with UID of the new message, then this will lead to infinite loop.
`OfflineIMAP`_ will upload the message to one server and delete on second. On
next run it will upload the message to second server and delete on first, etc.
Does OfflineIMAP support POP? Does OfflineIMAP support POP?
----------------------------- -----------------------------

View File

@ -1,7 +1,7 @@
__all__ = ['OfflineImap'] __all__ = ['OfflineImap']
__productname__ = 'OfflineIMAP' __productname__ = 'OfflineIMAP'
__version__ = "6.3.4-rc4" __version__ = "6.3.4"
__copyright__ = "Copyright 2002-2011 John Goerzen & contributors" __copyright__ = "Copyright 2002-2011 John Goerzen & contributors"
__author__ = "John Goerzen" __author__ = "John Goerzen"
__author_email__= "john@complete.org" __author_email__= "john@complete.org"

View File

@ -264,6 +264,14 @@ class BaseFolder(object):
uid = newuid uid = newuid
# Save uploaded status in the statusfolder # Save uploaded status in the statusfolder
statusfolder.savemessage(uid, message, flags, rtime) statusfolder.savemessage(uid, message, flags, rtime)
elif newuid == 0:
# Message was stored to dstfolder, but we can't find it's UID
# This means we can't link current message to the one created
# in IMAP. So we just delete local message and on next run
# we'll sync it back
# XXX This could cause infinite loop on syncing between two
# IMAP servers ...
self.deletemessage(uid)
else: else:
raise UserWarning("Trying to save msg (uid %d) on folder " raise UserWarning("Trying to save msg (uid %d) on folder "
"%s returned invalid uid %d" % \ "%s returned invalid uid %d" % \

View File

@ -276,7 +276,7 @@ class IMAPFolder(BaseFolder):
self.ui.debug('imap', self.ui.debug('imap',
'savemessage_addheader: called to add %s: %s' % (headername, 'savemessage_addheader: called to add %s: %s' % (headername,
headervalue)) headervalue))
insertionpoint = content.find("\r\n") insertionpoint = content.find("\r\n\r\n")
self.ui.debug('imap', 'savemessage_addheader: insertionpoint = %d' % insertionpoint) self.ui.debug('imap', 'savemessage_addheader: insertionpoint = %d' % insertionpoint)
leader = content[0:insertionpoint] leader = content[0:insertionpoint]
self.ui.debug('imap', 'savemessage_addheader: leader = %s' % repr(leader)) self.ui.debug('imap', 'savemessage_addheader: leader = %s' % repr(leader))
@ -409,8 +409,10 @@ class IMAPFolder(BaseFolder):
the new message after sucessfully saving it. the new message after sucessfully saving it.
:param rtime: A timestamp to be used as the mail date :param rtime: A timestamp to be used as the mail date
:returns: the UID of the new message as assigned by the :returns: the UID of the new message as assigned by the server. If the
server. If the folder is read-only it will return 0.""" message is saved, but it's UID can not be found, it will
return 0. If the message can't be written (folder is
read-only for example) it will return -1."""
self.ui.debug('imap', 'savemessage: called') self.ui.debug('imap', 'savemessage: called')
# already have it, just save modified flags # already have it, just save modified flags
@ -504,7 +506,7 @@ class IMAPFolder(BaseFolder):
return return
result = imapobj.uid('store', '%d' % uid, 'FLAGS', result = imapobj.uid('store', '%d' % uid, 'FLAGS',
imaputil.flagsmaildir2imap(flags)) imaputil.flagsmaildir2imap(flags))
assert result[0] == 'OK', 'Error with store: ' + '. '.join(r[1]) assert result[0] == 'OK', 'Error with store: ' + '. '.join(result[1])
finally: finally:
self.imapserver.releaseconnection(imapobj) self.imapserver.releaseconnection(imapobj)
result = result[1][0] result = result[1][0]