Permalink
Browse files

Drop connection if it might be bad on APPEND

1) Differentiate error messages between imaplib.abort and imaplib.error
exceptions in the log.

2) Drop connections in the case of imapobj.error, it also might denote a
   broken connection.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
  • Loading branch information...
1 parent 3aded16 commit dd02c307db3365ce64471f440aa7ddc58f5a2917 @spaetz spaetz committed Nov 2, 2011
Showing with 5 additions and 3 deletions.
  1. +5 −3 offlineimap/folder/IMAP.py
@@ -541,17 +541,19 @@ def savemessage(self, uid, content, flags, rtime):
imapobj = self.imapserver.acquireconnection()
if not retry_left:
raise OfflineImapError("Saving msg in folder '%s', "
- "repository '%s' failed. Server reponded: %s\n"
+ "repository '%s' failed (abort). Server reponded: %s\n"
"Message content was: %s" %
(self, self.getrepository(), str(e), dbg_output),
OfflineImapError.ERROR.MESSAGE)
self.ui.error(e, exc_info()[2])
-
except imapobj.error, e: # APPEND failed
# If the server responds with 'BAD', append()
# raise()s directly. So we catch that too.
+ # drop conn, it might be bad.
+ self.imapserver.releaseconnection(imapobj, True)
+ imapobj = None
raise OfflineImapError("Saving msg folder '%s', repo '%s'"
- "failed. Server reponded: %s\nMessage content was: "
+ "failed (error). Server reponded: %s\nMessage content was: "
"%s" % (self, self.getrepository(), str(e), dbg_output),
OfflineImapError.ERROR.MESSAGE)
# Checkpoint. Let it write out stuff, etc. Eg searches for

0 comments on commit dd02c30

Please sign in to comment.