From 105da1b0c35d6762865a56d10eaf2246716a11cb Mon Sep 17 00:00:00 2001 From: Ethan Glasser-Camp Date: Thu, 24 Mar 2011 14:51:10 -0400 Subject: [PATCH 1/2] Always logout() on imaplib2 objects, even during exceptions Without this, trying to Ctrl-C out of offlineimap will go into a hang. Signed-off-by: Ethan Glasser-Camp Reviewed-by: Sebastian Spaeth Signed-off-by: Nicolas Sebrecht --- Changelog.draft.rst | 2 ++ offlineimap/accounts.py | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Changelog.draft.rst b/Changelog.draft.rst index 0a85888..39490a1 100644 --- a/Changelog.draft.rst +++ b/Changelog.draft.rst @@ -19,6 +19,8 @@ Changes Bug Fixes --------- +* Fix hang when using Ctrl+C in some cases. + Pending for the next major release ================================== diff --git a/offlineimap/accounts.py b/offlineimap/accounts.py index 4903e39..7edfa37 100644 --- a/offlineimap/accounts.py +++ b/offlineimap/accounts.py @@ -265,10 +265,9 @@ class SyncableAccount(Account): mbnames.write() localrepos.forgetfolders() remoterepos.forgetfolders() + finally: localrepos.holdordropconnections() remoterepos.holdordropconnections() - finally: - pass hook = self.getconf('postsynchook', '') self.callhook(hook) From 09515f8f90cec06ffd880456b85d5c9c8a524d14 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Fri, 25 Mar 2011 10:19:30 +0100 Subject: [PATCH 2/2] Increase compatability with Gmail When uploading a new message to Gmail we need to find out the UID it assigned it, but Gmail does not advertize the UIDPLUS extension (in all cases) and it fails to find the email that we just uploaded when searching for it. This prevented us effectively from uploading to gmail. See analysis in http://lists.alioth.debian.org/pipermail/offlineimap-project/2011-March/001449.html for details on what is going wrong. This patch increases compatability with Gmail by checking for APPENDUID responses to an APPEND action even if the server did not claim to support it. This restores the capability to upload messages to the *broken* Gmail IMAP implementation. Signed-off-by: Sebastian Spaeth --- Changelog.draft.rst | 3 +++ offlineimap/folder/IMAP.py | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Changelog.draft.rst b/Changelog.draft.rst index 39490a1..79006fd 100644 --- a/Changelog.draft.rst +++ b/Changelog.draft.rst @@ -16,6 +16,9 @@ New Features Changes ------- +* Increase compatability with Gmail servers which claim to not support + the UIDPLUS extension but in reality do. + Bug Fixes --------- diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py index 74a9b87..828070c 100644 --- a/offlineimap/folder/IMAP.py +++ b/offlineimap/folder/IMAP.py @@ -439,8 +439,9 @@ class IMAPFolder(BaseFolder): (typ,dat) = imapobj.check() assert(typ == 'OK') - # get the UID. - if use_uidplus: + # get the new UID. Test for APPENDUID response even if the + # server claims to not support it, as e.g. Gmail does :-( + if use_uidplus or imapobj._get_untagged_response('APPENDUID', True): # get the new UID from the APPENDUID response, it could look like # OK [APPENDUID 38505 3955] APPEND completed # with 38505 bein folder UIDvalidity and 3955 the new UID