summaryrefslogtreecommitdiffstats
path: root/mailnews/local/src/nsLocalMailFolder.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2019-11-10 18:43:43 -0500
committerMatt A. Tobin <email@mattatobin.com>2019-11-10 18:43:43 -0500
commite60090bc9c7e14bb8253eeb64658aedaa0f863c7 (patch)
tree0d8b21f3ff848346d601c34c88bd35c76fb06d0a /mailnews/local/src/nsLocalMailFolder.cpp
parent1ec388b2383aa1540961843847d3af32174a248d (diff)
downloadUXP-e60090bc9c7e14bb8253eeb64658aedaa0f863c7.tar
UXP-e60090bc9c7e14bb8253eeb64658aedaa0f863c7.tar.gz
UXP-e60090bc9c7e14bb8253eeb64658aedaa0f863c7.tar.lz
UXP-e60090bc9c7e14bb8253eeb64658aedaa0f863c7.tar.xz
UXP-e60090bc9c7e14bb8253eeb64658aedaa0f863c7.zip
Bug 1427732 - fix newline handling when copying messages and compacting folders.
Tag #1273
Diffstat (limited to 'mailnews/local/src/nsLocalMailFolder.cpp')
-rw-r--r--mailnews/local/src/nsLocalMailFolder.cpp40
1 files changed, 21 insertions, 19 deletions
diff --git a/mailnews/local/src/nsLocalMailFolder.cpp b/mailnews/local/src/nsLocalMailFolder.cpp
index 14135fe46..00244ca87 100644
--- a/mailnews/local/src/nsLocalMailFolder.cpp
+++ b/mailnews/local/src/nsLocalMailFolder.cpp
@@ -2117,7 +2117,6 @@ nsresult nsMsgLocalMailFolder::WriteStartOfNewMessage()
nsresult nsMsgLocalMailFolder::InitCopyMsgHdrAndFileStream()
{
- nsCOMPtr<nsIMsgPluggableStore> msgStore;
nsresult rv = GetMsgStore(getter_AddRefs(mCopyState->m_msgStore));
NS_ENSURE_SUCCESS(rv, rv);
bool reusable;
@@ -2387,16 +2386,10 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndCopy(bool aCopySucceeded)
nsCOMPtr <nsISeekableStream> seekableStream(do_QueryInterface(mCopyState->m_fileStream));
if (seekableStream)
{
- if (mCopyState->m_dummyEnvelopeNeeded)
- {
- uint32_t bytesWritten;
- seekableStream->Seek(nsISeekableStream::NS_SEEK_END, 0);
- mCopyState->m_fileStream->Write(MSG_LINEBREAK, MSG_LINEBREAK_LEN, &bytesWritten);
- if (mCopyState->m_parseMsgState)
- mCopyState->m_parseMsgState->ParseAFolderLine(CRLF, MSG_LINEBREAK_LEN);
- }
- rv = mCopyState->m_msgStore->FinishNewMessage(mCopyState->m_fileStream,
- mCopyState->m_newHdr);
+ seekableStream->Seek(nsISeekableStream::NS_SEEK_END, 0);
+ rv = FinishNewLocalMessage(mCopyState->m_fileStream, mCopyState->m_newHdr,
+ mCopyState->m_msgStore,
+ mCopyState->m_parseMsgState);
if (NS_SUCCEEDED(rv) && mCopyState->m_newHdr)
mCopyState->m_newHdr->GetMessageKey(&mCopyState->m_curDstKey);
if (multipleCopiesFinished)
@@ -2714,13 +2707,9 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndMessage(nsMsgKey key)
nsCOMPtr <nsISeekableStream> seekableStream = do_QueryInterface(mCopyState->m_fileStream, &rv);
NS_ENSURE_SUCCESS(rv, rv);
seekableStream->Seek(nsISeekableStream::NS_SEEK_END, 0);
- uint32_t bytesWritten;
- mCopyState->m_fileStream->Write(MSG_LINEBREAK, MSG_LINEBREAK_LEN, &bytesWritten);
- if (mCopyState->m_parseMsgState)
- mCopyState->m_parseMsgState->ParseAFolderLine(CRLF, MSG_LINEBREAK_LEN);
-
- rv = mCopyState->m_msgStore->FinishNewMessage(mCopyState->m_fileStream,
- mCopyState->m_newHdr);
+ rv = FinishNewLocalMessage(mCopyState->m_fileStream, mCopyState->m_newHdr,
+ mCopyState->m_msgStore,
+ mCopyState->m_parseMsgState);
mCopyState->m_fileStream->Close();
mCopyState->m_fileStream = nullptr; // all done with the file stream
@@ -3739,7 +3728,7 @@ nsMsgLocalMailFolder::AddMessageBatch(uint32_t aMessageCount,
outFileStream->Write(aMessages[i], messageLen, &bytesWritten);
newMailParser->BufferInput(aMessages[i], messageLen);
- msgStore->FinishNewMessage(outFileStream, newHdr);
+ FinishNewLocalMessage(outFileStream, newHdr, msgStore, newMailParser);
outFileStream->Close();
outFileStream = nullptr;
newMailParser->OnStopRequest(nullptr, nullptr, NS_OK);
@@ -3752,6 +3741,19 @@ nsMsgLocalMailFolder::AddMessageBatch(uint32_t aMessageCount,
return rv;
}
+nsresult
+nsMsgLocalMailFolder::FinishNewLocalMessage(nsIOutputStream *aOutputStream,
+ nsIMsgDBHdr *aNewHdr,
+ nsIMsgPluggableStore *aMsgStore,
+ nsParseMailMessageState *aParseMsgState)
+{
+ uint32_t bytesWritten;
+ aOutputStream->Write(MSG_LINEBREAK, MSG_LINEBREAK_LEN, &bytesWritten);
+ if (aParseMsgState)
+ aParseMsgState->ParseAFolderLine(MSG_LINEBREAK, MSG_LINEBREAK_LEN);
+ return aMsgStore->FinishNewMessage(aOutputStream, aNewHdr);
+}
+
NS_IMETHODIMP
nsMsgLocalMailFolder::WarnIfLocalFileTooBig(nsIMsgWindow *aWindow,
int64_t aSpaceRequested,