Revert "Clean up and improve APPENDUID handling"
This reverts commit 4d47f7bf3c
.
This is one of two candidates for introducing the instabilities that
John Wiegley observed. We need to reintroduce with careful testing only.
The original patch has been mostly reverted.
This commit is contained in:
parent
bc73c11239
commit
0e6b4ae798
@ -539,10 +539,9 @@ class IMAPFolder(BaseFolder):
|
|||||||
self.ui.msgtoreadonly(self, uid, content, flags)
|
self.ui.msgtoreadonly(self, uid, content, flags)
|
||||||
return uid
|
return uid
|
||||||
|
|
||||||
# Clean out existing APPENDUID responses and do APPEND
|
#Do the APPEND
|
||||||
try:
|
try:
|
||||||
imapobj.response('APPENDUID') # flush APPENDUID responses
|
(typ, dat) = imapobj.append(self.getfullname(),
|
||||||
typ, dat = imapobj.append(self.getfullname(),
|
|
||||||
imaputil.flagsmaildir2imap(flags),
|
imaputil.flagsmaildir2imap(flags),
|
||||||
date, content)
|
date, content)
|
||||||
retry_left = 0 # Mark as success
|
retry_left = 0 # Mark as success
|
||||||
@ -570,33 +569,34 @@ class IMAPFolder(BaseFolder):
|
|||||||
OfflineImapError.ERROR.MESSAGE)
|
OfflineImapError.ERROR.MESSAGE)
|
||||||
# Checkpoint. Let it write out stuff, etc. Eg searches for
|
# Checkpoint. Let it write out stuff, etc. Eg searches for
|
||||||
# just uploaded messages won't work if we don't do this.
|
# just uploaded messages won't work if we don't do this.
|
||||||
typ, dat = imapobj.check()
|
(typ,dat) = imapobj.check()
|
||||||
assert(typ == 'OK')
|
assert(typ == 'OK')
|
||||||
|
|
||||||
# get the new UID, default to 0 (=unknown)
|
# get the new UID. Test for APPENDUID response even if the
|
||||||
uid = 0
|
# server claims to not support it, as e.g. Gmail does :-(
|
||||||
if use_uidplus:
|
if use_uidplus or imapobj._get_untagged_response('APPENDUID', True):
|
||||||
# get new UID from the APPENDUID response, it could look
|
# get new UID from the APPENDUID response, it could look
|
||||||
# like OK [APPENDUID 38505 3955] APPEND completed with
|
# like OK [APPENDUID 38505 3955] APPEND completed with
|
||||||
# 38505 being folder UIDvalidity and 3955 the new UID.
|
# 38505 bein folder UIDvalidity and 3955 the new UID.
|
||||||
typ, resp = imapobj.response('APPENDUID')
|
# note: we would want to use .response() here but that
|
||||||
if resp == [None] or resp == None:
|
# often seems to return [None], even though we have
|
||||||
|
# data. TODO
|
||||||
|
resp = imapobj._get_untagged_response('APPENDUID')
|
||||||
|
if resp == [None]:
|
||||||
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.")
|
||||||
else:
|
return 0
|
||||||
uid = long(resp[-1].split(' ')[1])
|
uid = long(resp[-1].split(' ')[1])
|
||||||
if uid == 0:
|
if uid == 0:
|
||||||
self.ui.warn("savemessage: Server supports UIDPLUS, but"
|
self.ui.warn("savemessage: Server supports UIDPLUS, but"
|
||||||
" we got no usable uid back. APPENDUID reponse was "
|
" we got no usable uid back. APPENDUID reponse was "
|
||||||
"'%s'" % str(resp))
|
"'%s'" % str(resp))
|
||||||
else:
|
else:
|
||||||
# Don't support UIDPLUS
|
# we don't support UIDPLUS
|
||||||
uid = self.savemessage_searchforheader(imapobj, headername,
|
uid = self.savemessage_searchforheader(imapobj, headername,
|
||||||
headervalue)
|
headervalue)
|
||||||
# If everything failed up to here, search the message
|
# See docs for savemessage in Base.py for explanation
|
||||||
# manually TODO: rather than inserting and searching for our
|
# of this and other return values
|
||||||
# custom header, we should be searching the Message-ID and
|
|
||||||
# compare the message size...
|
|
||||||
if uid == 0:
|
if uid == 0:
|
||||||
self.ui.debug('imap', 'savemessage: attempt to get new UID '
|
self.ui.debug('imap', 'savemessage: attempt to get new UID '
|
||||||
'UID failed. Search headers manually.')
|
'UID failed. Search headers manually.')
|
||||||
|
Loading…
Reference in New Issue
Block a user