Bug 912465 - Use MsgNewSafeBufferedFileOutputStream instead of NewLocalFileOutputStream in nsMsgFilterService.cpp. r=irving
authorJohannes Buchner <buchner.johannes@gmx.at>
Thu, 21 Nov 2013 09:01:31 -0500
changeset 13298 9b1106f87c8c
parent 13297 eb971b974099
child 13299 7b725655e48f
push id9665
push userryanvm@gmail.com
push dateThu, 21 Nov 2013 14:03:18 +0000
treeherdercomm-central@d7853d9e9971 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersirving
bugs912465
Bug 912465 - Use MsgNewSafeBufferedFileOutputStream instead of NewLocalFileOutputStream in nsMsgFilterService.cpp. r=irving
mailnews/base/search/src/nsMsgFilterService.cpp
--- a/mailnews/base/search/src/nsMsgFilterService.cpp
+++ b/mailnews/base/search/src/nsMsgFilterService.cpp
@@ -121,33 +121,31 @@ NS_IMETHODIMP nsMsgFilterService::CloseF
 }
 
 /* save without deleting */
 NS_IMETHODIMP  nsMsgFilterService::SaveFilterList(nsIMsgFilterList *filterList, nsIFile *filterFile)
 {
   NS_ENSURE_ARG_POINTER(filterFile);
   NS_ENSURE_ARG_POINTER(filterList);
 
-  nsCOMPtr<nsIOutputStream> out;
-  nsresult rv = NS_NewSafeLocalFileOutputStream(getter_AddRefs(out),
+  nsCOMPtr<nsIOutputStream> strm;
+  nsresult rv = MsgNewSafeBufferedFileOutputStream(getter_AddRefs(strm),
                                                 filterFile, -1, 0600);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIOutputStream> strm;
-  rv = NS_NewBufferedOutputStream(getter_AddRefs(strm), out, 4096);
-  NS_ENSURE_SUCCESS(rv, rv);
-
   rv = filterList->SaveToFile(strm);
 
   nsCOMPtr<nsISafeOutputStream> safeStream = do_QueryInterface(strm);
-  NS_ASSERTION(safeStream, "expected a safe output stream");
-  if (NS_SUCCEEDED(rv) && safeStream)
+  NS_ASSERTION(safeStream, "expected a safe output stream!");
+  if (safeStream) {
     rv = safeStream->Finish();
-
-  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to save filter file");
+    if (NS_FAILED(rv)) {
+      NS_WARNING("failed to save filter file! possible data loss");
+    }
+  }
   return rv;
 }
 
 NS_IMETHODIMP nsMsgFilterService::CancelFilterList(nsIMsgFilterList *filterList)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }