From 347e1eaa3228a5aeac8d5375189646a5fb564f31 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Wed, 21 Sep 2011 02:16:33 +0200 Subject: [PATCH] update CAPABILITIES after login Some Webservers (I am looking at you Gmail) send different capabilities before and after login, so they can tailor their server capabilities to the user. While legal, this is uncommon and we were not updating our server capabilities. Doing so allows us to detect that Gmail actually supports the UIDPLUS extension, and we will stop mangling headers when uploading to Gmail. This could lead to some performance gains when we upload many messages to Gmail. Signed-off-by: Sebastian Spaeth --- Changelog.draft.rst | 4 ++++ offlineimap/imapserver.py | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Changelog.draft.rst b/Changelog.draft.rst index 76a0ea3..9bae1d8 100644 --- a/Changelog.draft.rst +++ b/Changelog.draft.rst @@ -16,5 +16,9 @@ New Features Changes ------- +* Refresh server capabilities after login, so we know that Gmail + supports UIDPLUS (it only announces that after login, not + before). This prevents us from adding custom headers to Gmail uploads. + Bug Fixes --------- diff --git a/offlineimap/imapserver.py b/offlineimap/imapserver.py index dc0bc50..ead3280 100644 --- a/offlineimap/imapserver.py +++ b/offlineimap/imapserver.py @@ -1,6 +1,5 @@ # IMAP server support -# Copyright (C) 2002 - 2007 John Goerzen -# +# Copyright (C) 2002 - 2011 John Goerzen & contributors # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -276,6 +275,11 @@ class IMAPServer: self.passworderror = str(val) raise + # update capabilities after login, e.g. gmail serves different ones + typ, dat = imapobj.capability() + if dat != [None]: + imapobj.capabilities = tuple(dat[-1].upper().split()) + if self.delim == None: listres = imapobj.list(self.reference, '""')[1] if listres == [None] or listres == None: