SEVERE: Fix getting wrong UID back on IMAP upload
This change looks harmless, but it fixes a severe bugfix, potentially leading to data loss! It fixes the "on n new uploads, it will redownload n-1, n-2, n-3,... messages during the next syncs" condition, and this is what happens: If there are more than one Mails to upload to a server, we do that by repeatedly invoking folder.IMAP.savemessage(). If the server supports the UIDPLUS extension we query the resulting UID by doing a: imapobj._get_untagged_response('APPENDUID', True) and that is exactly the problem. The "True" part causes the reply to remain in the "response stack" of the imaplib2 library. When we do the same call on a subsequent message and the connection is still on the same folder, we will get the same UID response back (imaplib2 only looks for the first matching response and returns that). The only time we clear the response stack, is when the IMAP connection SELECTS a different folder. This means that when we upload 10 messages, the IMAP server gives us always the same UID (that of the first one) back. And trying to write out 10 different messages with the same UID will confuse OfflineIMAP. This is the reason why we saw the ongoing UPLOADING/DOWNLOADING behavior that people reported. And this is the reason why we saw the inconsistency in the UID mapping in the IMAP<->IMAP case. I urge everyone to upgrade ASAP. Sorry for that, I don't know why the problem only became prevalent in the recent few releases as this code has been there for quite a while. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
parent
0ea6c6ed47
commit
8fc7227189
@ -570,7 +570,7 @@ class IMAPFolder(BaseFolder):
|
|||||||
self.ui.warn("Server supports UIDPLUS but got no APPENDUID "
|
self.ui.warn("Server supports UIDPLUS but got no APPENDUID "
|
||||||
"appending a message.")
|
"appending a message.")
|
||||||
return 0
|
return 0
|
||||||
uid = long(imapobj._get_untagged_response('APPENDUID', True)[-1].split(' ')[1])
|
uid = long(imapobj._get_untagged_response('APPENDUID')[-1].split(' ')[1])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# we don't support UIDPLUS
|
# we don't support UIDPLUS
|
||||||
|
Loading…
Reference in New Issue
Block a user