Don't embed CRLF multiple times when saving a message
Since we just do multiple passes for saving the message without actually modifying its content (apart from header insertion that is CRLF-clean), we can change line ends to the proper CRLF just once. And we can also get message's date only once too. Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
This commit is contained in:
parent
0903428fda
commit
844ca6b08c
@ -509,6 +509,12 @@ class IMAPFolder(BaseFolder):
|
|||||||
self.savemessageflags(uid, flags)
|
self.savemessageflags(uid, flags)
|
||||||
return uid
|
return uid
|
||||||
|
|
||||||
|
# Use proper CRLF all over the message
|
||||||
|
content = re.sub("(?<!\r)\n", "\r\n", content)
|
||||||
|
|
||||||
|
# get the date of the message, so we can pass it to the server.
|
||||||
|
date = self.__getmessageinternaldate(content, rtime)
|
||||||
|
|
||||||
retry_left = 2 # succeeded in APPENDING?
|
retry_left = 2 # succeeded in APPENDING?
|
||||||
imapobj = self.imapserver.acquireconnection()
|
imapobj = self.imapserver.acquireconnection()
|
||||||
# NB: in the finally clause for this try we will release
|
# NB: in the finally clause for this try we will release
|
||||||
@ -521,10 +527,6 @@ class IMAPFolder(BaseFolder):
|
|||||||
# UIDPLUS extension provides us with an APPENDUID response.
|
# UIDPLUS extension provides us with an APPENDUID response.
|
||||||
use_uidplus = 'UIDPLUS' in imapobj.capabilities
|
use_uidplus = 'UIDPLUS' in imapobj.capabilities
|
||||||
|
|
||||||
# get the date of the message, so we can pass it to the server.
|
|
||||||
date = self.__getmessageinternaldate(content, rtime)
|
|
||||||
content = re.sub("(?<!\r)\n", "\r\n", content)
|
|
||||||
|
|
||||||
if not use_uidplus:
|
if not use_uidplus:
|
||||||
# insert a random unique header that we can fetch later
|
# insert a random unique header that we can fetch later
|
||||||
(headername, headervalue) = self.__generate_randomheader(
|
(headername, headervalue) = self.__generate_randomheader(
|
||||||
|
Loading…
Reference in New Issue
Block a user