Bug 782868 - nsIMsgFolderCompactor.compact should notify errors. r=Standard8
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Thu, 31 Oct 2013 23:25:57 -0400
changeset 16855 6878aac88d589ce4568f69e37ec823bcb442bfbb
parent 16854 4a83d411ad625cad5a21b70b4bff183ea9742945
child 16856 9c812d89f8c91b3dee202e1f41ccef883d034ce1
push id1074
push userbugzilla@standard8.plus.com
push dateMon, 03 Feb 2014 22:47:23 +0000
treeherdercomm-beta@6b791b5369ed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8
bugs782868
Bug 782868 - nsIMsgFolderCompactor.compact should notify errors. r=Standard8
mailnews/base/src/nsMsgFolderCompactor.cpp
--- a/mailnews/base/src/nsMsgFolderCompactor.cpp
+++ b/mailnews/base/src/nsMsgFolderCompactor.cpp
@@ -480,18 +480,19 @@ nsFolderCompactState::FinishCompact()
       }
     }
     // We don't want any temporarily renamed summary file to lie around
     if (tempSummaryFile)
       tempSummaryFile->Remove(false);
   }
 
   NS_WARN_IF_FALSE(msfRenameSucceeded, "compact failed");
-  rv = ReleaseFolderLock();
-  NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),"folder lock not released successfully");
+  nsresult rvReleaseFolderLock = ReleaseFolderLock();
+  NS_WARN_IF_FALSE(NS_SUCCEEDED(rvReleaseFolderLock),"folder lock not released successfully");
+  rv = NS_FAILED(rv) ? rv : rvReleaseFolderLock;
 
   // Cleanup of nstmp-named compacted files if failure
   if (!folderRenameSucceeded)
   {
     // remove the abandoned compacted version with the wrong name
     m_file->Remove(false);
   }
   if (!msfRenameSucceeded)
@@ -503,16 +504,19 @@ nsFolderCompactState::FinishCompact()
   if (msfRenameSucceeded)
   {
     // Transfer local db information from transferInfo
     nsCOMPtr<nsIMsgDBService> msgDBService =
       do_GetService(NS_MSGDB_SERVICE_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
     rv = msgDBService->OpenFolderDB(m_folder, true, getter_AddRefs(m_db));
     NS_ENSURE_TRUE(m_db, NS_FAILED(rv) ? rv : NS_ERROR_FAILURE);
+    // These errors are expected.
+    rv = (rv == NS_MSG_ERROR_FOLDER_SUMMARY_MISSING ||
+          rv == NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE) ? NS_OK : rv;
     m_db->SetSummaryValid(true);
     m_folder->SetDBTransferInfo(transferInfo);
 
     // since we're transferring info from the old db, we need to reset the expunged bytes
     nsCOMPtr<nsIDBFolderInfo> dbFolderInfo;
     m_db->GetDBFolderInfo(getter_AddRefs(dbFolderInfo));
     if(dbFolderInfo)
       dbFolderInfo->SetExpungedBytes(0);
@@ -528,17 +532,17 @@ nsFolderCompactState::FinishCompact()
     notifier->NotifyItemEvent(m_folder,
                               NS_LITERAL_CSTRING("FolderCompactFinish"),
                               nullptr);
   m_folder->NotifyCompactCompleted();
 
   if (m_compactAll)
     rv = CompactNextFolder();
   else
-    CompactCompleted(NS_OK);
+    CompactCompleted(rv);
       
   return rv;
 }
 
 void nsFolderCompactState::CompactCompleted(nsresult exitCode)
 {
   NS_WARN_IF_FALSE(NS_SUCCEEDED(exitCode),
                    "nsFolderCompactState::CompactCompleted failed");