make savemessage() handle NO response to APPEND correctly
IMAP servers can return `NO` responses to the `APPEND` command,
e.g. here's an example response from Groupwise's IMAP server:
    NO APPEND The 1500 MB storage limit has been exceeded.
In this case, savemessage() should abort the repository sync rather
than returning UID 0 which would cause the local copy of the message
being saved to get irreversibly deleted.
Signed-off-by: Adam Spiers <offlineimap@adamspiers.org>
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
			
			
This commit is contained in:
		 Adam Spiers
					Adam Spiers
				
			
				
					committed by
					
						 Eygene Ryabinkin
						Eygene Ryabinkin
					
				
			
			
				
	
			
			
			 Eygene Ryabinkin
						Eygene Ryabinkin
					
				
			
						parent
						
							3a580049ad
						
					
				
				
					commit
					d39a1f864f
				
			| @@ -548,7 +548,21 @@ class IMAPFolder(BaseFolder): | ||||
|                     (typ, dat) = imapobj.append(self.getfullname(), | ||||
|                                        imaputil.flagsmaildir2imap(flags), | ||||
|                                        date, content) | ||||
|                     retry_left = 0                # Mark as success | ||||
|                     # This should only catch 'NO' responses since append() | ||||
|                     # will raise an exception for 'BAD' responses: | ||||
|                     if typ != 'OK': | ||||
|                         # For example, Groupwise IMAP server can return something like: | ||||
|                         # | ||||
|                         #   NO APPEND The 1500 MB storage limit has been exceeded. | ||||
|                         # | ||||
|                         # In this case, we should immediately abort the repository sync | ||||
|                         # and continue with the next account. | ||||
|                         msg = \ | ||||
|                             "Saving msg in folder '%s', repository '%s' failed (abort). " \ | ||||
|                             "Server responded: %s %s\n" % \ | ||||
|                             (self, self.getrepository(), typ, dat) | ||||
|                         raise OfflineImapError(msg, OfflineImapError.ERROR.REPO) | ||||
|                     retry_left = 0 # Mark as success | ||||
|                 except imapobj.abort as e: | ||||
|                     # connection has been reset, release connection and retry. | ||||
|                     retry_left -= 1 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user