From 86e9c7442bed8703e059cdcbd18bbea71c513ae8 Mon Sep 17 00:00:00 2001 From: Vladimir Marek Date: Tue, 26 Jul 2011 10:59:53 +0200 Subject: [PATCH 1/5] Include message header at better place It's not enough to place header after first newline, since this might break multiline rfc0822 folded long header lines. Those are difined as CRLF followed by white space. Instead we'll search for two successive CRLF sequences which mark end of mail headers and place our header just before that. Signed-off-by: Vladimir Marek Signed-off-by: Nicolas Sebrecht --- offlineimap/folder/IMAP.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py index 9297a7b..19a0340 100644 --- a/offlineimap/folder/IMAP.py +++ b/offlineimap/folder/IMAP.py @@ -276,7 +276,7 @@ class IMAPFolder(BaseFolder): self.ui.debug('imap', 'savemessage_addheader: called to add %s: %s' % (headername, headervalue)) - insertionpoint = content.find("\r\n") + insertionpoint = content.find("\r\n\r\n") self.ui.debug('imap', 'savemessage_addheader: insertionpoint = %d' % insertionpoint) leader = content[0:insertionpoint] self.ui.debug('imap', 'savemessage_addheader: leader = %s' % repr(leader)) From d5cbdc4c0e51842af4979c63297e22f7971ae62b Mon Sep 17 00:00:00 2001 From: Vladimir Marek Date: Tue, 26 Jul 2011 10:59:54 +0200 Subject: [PATCH 2/5] Handle when UID can't be found on saved messages 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. Also fixed imap.savemessage description. This was broken by e20d8b967942934ddbf4659b5ec328a9a18da6bc. Signed-off-by: Vladimir Marek Signed-off-by: Nicolas Sebrecht --- offlineimap/folder/Base.py | 8 ++++++++ offlineimap/folder/IMAP.py | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py index 608d361..0d5ddae 100644 --- a/offlineimap/folder/Base.py +++ b/offlineimap/folder/Base.py @@ -264,6 +264,14 @@ class BaseFolder(object): uid = newuid # Save uploaded status in the statusfolder 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: raise UserWarning("Trying to save msg (uid %d) on folder " "%s returned invalid uid %d" % \ diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py index 19a0340..1fa35f7 100644 --- a/offlineimap/folder/IMAP.py +++ b/offlineimap/folder/IMAP.py @@ -409,8 +409,10 @@ class IMAPFolder(BaseFolder): the new message after sucessfully saving it. :param rtime: A timestamp to be used as the mail date - :returns: the UID of the new message as assigned by the - server. If the folder is read-only it will return 0.""" + :returns: the UID of the new message as assigned by the server. If the + 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') # already have it, just save modified flags From e58399ac0b8f7542bf6cb6e25a87004af25f38f3 Mon Sep 17 00:00:00 2001 From: Vladimir Marek Date: Tue, 26 Jul 2011 10:59:55 +0200 Subject: [PATCH 3/5] Fixed typo Signed-off-by: Vladimir Marek Signed-off-by: Nicolas Sebrecht --- offlineimap/folder/IMAP.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py index 1fa35f7..3c702f4 100644 --- a/offlineimap/folder/IMAP.py +++ b/offlineimap/folder/IMAP.py @@ -506,7 +506,7 @@ class IMAPFolder(BaseFolder): return result = imapobj.uid('store', '%d' % uid, '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: self.imapserver.releaseconnection(imapobj) result = result[1][0] From 9d5f805981b2db9d9265c41c8a28bcf8f5784dc0 Mon Sep 17 00:00:00 2001 From: Vladimir Marek Date: Sun, 31 Jul 2011 10:48:24 +0200 Subject: [PATCH 4/5] FAQ: add commant about UID not found on saved messages This add missing doc as requested on the mailing list for commit d5cbdc4c0e5. Also, add an entry in the changelog. Signed-off-by: Vladimir Marek Signed-off-by: Nicolas Sebrecht --- Changelog.draft.rst | 2 ++ docs/FAQ.rst | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/Changelog.draft.rst b/Changelog.draft.rst index e840717..938a5e6 100644 --- a/Changelog.draft.rst +++ b/Changelog.draft.rst @@ -13,6 +13,8 @@ others. New Features ------------ +* Handle when UID can't be found on saved messages. + Changes ------- diff --git a/docs/FAQ.rst b/docs/FAQ.rst index cebe766..3181a8a 100644 --- a/docs/FAQ.rst +++ b/docs/FAQ.rst @@ -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 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? ----------------------------- From 61e50b3b1a81a564697a74384f528b22dfd32d8b Mon Sep 17 00:00:00 2001 From: Nicolas Sebrecht Date: Wed, 10 Aug 2011 21:44:58 +0200 Subject: [PATCH 5/5] v6.3.4 Signed-off-by: Nicolas Sebrecht --- Changelog.draft.rst | 2 -- Changelog.rst | 14 ++++++++++++++ offlineimap/__init__.py | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Changelog.draft.rst b/Changelog.draft.rst index 938a5e6..e840717 100644 --- a/Changelog.draft.rst +++ b/Changelog.draft.rst @@ -13,8 +13,6 @@ others. New Features ------------ -* Handle when UID can't be found on saved messages. - Changes ------- diff --git a/Changelog.rst b/Changelog.rst index c872055..95a13b8 100644 --- a/Changelog.rst +++ b/Changelog.rst @@ -12,6 +12,20 @@ ChangeLog 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) =================================== diff --git a/offlineimap/__init__.py b/offlineimap/__init__.py index d35df7f..5070ac7 100644 --- a/offlineimap/__init__.py +++ b/offlineimap/__init__.py @@ -1,7 +1,7 @@ __all__ = ['OfflineImap'] __productname__ = 'OfflineIMAP' -__version__ = "6.3.4-rc4" +__version__ = "6.3.4" __copyright__ = "Copyright 2002-2011 John Goerzen & contributors" __author__ = "John Goerzen" __author_email__= "john@complete.org"