IMAP: Don't use assert() in folder.savemessage()
We simply assert()ed that APPENDing a message returned OK, but in some cases (e.g. Google chat messages) APPEND might return BAD or NO too. We should be throwing an OfflineImapError here at MESSAGE level, so that we can continue to sync all other messages, and still give the user some details on what went wrong at the end of the sync run. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de> Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
b47bc44783
commit
f6b9c68333
@ -450,16 +450,20 @@ class IMAPFolder(BaseFolder):
|
||||
content[-50:])
|
||||
else:
|
||||
dbg_output = content
|
||||
|
||||
self.ui.debug('imap', "savemessage: date: %s, content: '%s'" %
|
||||
(date, dbg_output))
|
||||
|
||||
#Do the APPEND
|
||||
(typ, dat) = imapobj.append(self.getfullname(),
|
||||
imaputil.flagsmaildir2imap(flags),
|
||||
date, content)
|
||||
assert(typ == 'OK')
|
||||
|
||||
# Checkpoint. Let it write out the messages, etc.
|
||||
if typ != 'OK': #APPEND failed
|
||||
raise OfflineImapError("Saving msg in folder '%s', repository "
|
||||
"'%s' failed. Server reponded; %s %s\nMessage content was:"
|
||||
" %s" % (self, self.getrepository(), typ, dat, dbg_output),
|
||||
OfflineImapError.ERROR.MESSAGE)
|
||||
# Checkpoint. Let it write out stuff, etc. Eg searches for
|
||||
# just uploaded messages won't work if we don't do this.
|
||||
(typ,dat) = imapobj.check()
|
||||
assert(typ == 'OK')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user