From 14f4631e3d4ac14843cdb5dbd3f890015038e800 Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Tue, 19 Nov 2013 11:13:39 -0500 Subject: [PATCH] Backed out changeset e75d5882e8b2 (bug 912465) for xpcshell crashes on a CLOSED TREE. --- .../base/search/src/nsMsgFilterService.cpp | 18 ++++++++------- mailnews/base/src/nsMsgAccountManager.cpp | 22 +++++++++---------- mailnews/base/util/nsMsgMailNewsUrl.cpp | 14 ++++-------- mailnews/local/src/nsPop3Protocol.cpp | 8 +------ 4 files changed, 25 insertions(+), 37 deletions(-) diff --git a/mailnews/base/search/src/nsMsgFilterService.cpp b/mailnews/base/search/src/nsMsgFilterService.cpp index c9ac80abf6..df35c45178 100644 --- a/mailnews/base/search/src/nsMsgFilterService.cpp +++ b/mailnews/base/search/src/nsMsgFilterService.cpp @@ -126,21 +126,23 @@ NS_IMETHODIMP nsMsgFilterService::SaveFilterList(nsIMsgFilterList *filterList, NS_ENSURE_ARG_POINTER(filterFile); NS_ENSURE_ARG_POINTER(filterList); - nsCOMPtr strm; - nsresult rv = MsgNewSafeBufferedFileOutputStream(getter_AddRefs(strm), + nsCOMPtr out; + nsresult rv = NS_NewSafeLocalFileOutputStream(getter_AddRefs(out), filterFile, -1, 0600); NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr strm; + rv = NS_NewBufferedOutputStream(getter_AddRefs(strm), out, 4096); + NS_ENSURE_SUCCESS(rv, rv); + rv = filterList->SaveToFile(strm); nsCOMPtr safeStream = do_QueryInterface(strm); - NS_ASSERTION(safeStream, "expected a safe output stream!"); - if (safeStream) { + NS_ASSERTION(safeStream, "expected a safe output stream"); + if (NS_SUCCEEDED(rv) && safeStream) rv = safeStream->Finish(); - if (NS_FAILED(rv)) { - NS_WARNING("failed to save filter file! possible data loss"); - } - } + + NS_ASSERTION(NS_SUCCEEDED(rv), "failed to save filter file"); return rv; } diff --git a/mailnews/base/src/nsMsgAccountManager.cpp b/mailnews/base/src/nsMsgAccountManager.cpp index 0ab0dc8995..57b45ec699 100644 --- a/mailnews/base/src/nsMsgAccountManager.cpp +++ b/mailnews/base/src/nsMsgAccountManager.cpp @@ -3126,25 +3126,23 @@ NS_IMETHODIMP nsMsgAccountManager::SaveVirtualFolders() GetVirtualFoldersFile(file); // Open a buffered, safe output stream + nsCOMPtr outStreamSink; + nsresult rv = NS_NewSafeLocalFileOutputStream(getter_AddRefs(outStreamSink), + file, + PR_CREATE_FILE | PR_WRONLY | PR_TRUNCATE, + 0664); + NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr outStream; - nsresult rv = MsgNewSafeBufferedFileOutputStream(getter_AddRefs(outStream), - file, - PR_CREATE_FILE | PR_WRONLY | PR_TRUNCATE, - 0664); + rv = NS_NewBufferedOutputStream(getter_AddRefs(outStream), outStreamSink, 4096); NS_ENSURE_SUCCESS(rv, rv); WriteLineToOutputStream("version=", "1", outStream); m_incomingServers.Enumerate(saveVirtualFolders, &outStream); nsCOMPtr safeStream = do_QueryInterface(outStream, &rv); - NS_ASSERTION(safeStream, "expected a safe output stream!"); - if (safeStream) { - rv = safeStream->Finish(); - if (NS_FAILED(rv)) { - NS_WARNING("failed to save personal dictionary file! possible data loss"); - } - } - return rv; + NS_ENSURE_SUCCESS(rv, rv); + return safeStream->Finish(); } PLDHashOperator diff --git a/mailnews/base/util/nsMsgMailNewsUrl.cpp b/mailnews/base/util/nsMsgMailNewsUrl.cpp index 38937026ca..dc94753c8b 100644 --- a/mailnews/base/util/nsMsgMailNewsUrl.cpp +++ b/mailnews/base/util/nsMsgMailNewsUrl.cpp @@ -912,7 +912,9 @@ nsresult nsMsgSaveAsListener::SetupMsgWriteStream(nsIFile *aFile, bool addDummyE // have to close the stream before deleting the file, else data // would still be written happily into a now non-existing file. // (Windows doesn't care, btw, just unixoids do...) - nsresult rv = MsgNewSafeBufferedFileOutputStream(getter_AddRefs(m_outputStream), + aFile->Remove(false); + + nsresult rv = MsgNewBufferedFileOutputStream(getter_AddRefs(m_outputStream), aFile, -1, 0666); NS_ENSURE_SUCCESS(rv, rv); @@ -936,15 +938,7 @@ nsresult nsMsgSaveAsListener::SetupMsgWriteStream(nsIFile *aFile, bool addDummyE result += MSG_LINEBREAK; m_outputStream->Write(result.get(), result.Length(), &writeCount); } - NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr safeStream = do_QueryInterface(m_outputStream); - NS_ASSERTION(safeStream, "expected a safe output stream!"); - if (safeStream) { - rv = safeStream->Finish(); - if (NS_FAILED(rv)) { - NS_WARNING("failed to save msg file! possible data loss"); - } - } + return rv; } diff --git a/mailnews/local/src/nsPop3Protocol.cpp b/mailnews/local/src/nsPop3Protocol.cpp index 76e2075ba2..5e3217058d 100644 --- a/mailnews/local/src/nsPop3Protocol.cpp +++ b/mailnews/local/src/nsPop3Protocol.cpp @@ -353,13 +353,7 @@ net_pop3_write_state(Pop3UidlHost* host, nsIFile *mailDirectory) } } nsCOMPtr safeStream = do_QueryInterface(fileOutputStream); - NS_ASSERTION(safeStream, "expected a safe output stream!"); - if (safeStream) { - rv = safeStream->Finish(); - if (NS_FAILED(rv)) { - NS_WARNING("failed to save pop state! possible data loss"); - } - } + safeStream->Finish(); } static void