Bug 619358 - compact crash [@ nsFolderCompactState::OnStopRunningUrl(nsIURI*, unsigned int)]; r=Standard8
authorDavid Bienvenu <bienvenu@nventure.com>
Mon, 20 Dec 2010 09:02:25 +0000
changeset 6862 0fdf675ff82f69da60cb9fe5f77e104ba4d92e99
parent 6861 97da7450f2a07fb814d0e4f3e9554c910eba6203
child 6863 e65a8ebcdfc2bc749abff80d8c581f94ac528ec5
push idunknown
push userunknown
push dateunknown
reviewersStandard8
bugs619358
Bug 619358 - compact crash [@ nsFolderCompactState::OnStopRunningUrl(nsIURI*, unsigned int)]; r=Standard8
mailnews/base/src/nsMsgFolderCompactor.cpp
mailnews/base/test/unit/test_folderCompact.js
--- a/mailnews/base/src/nsMsgFolderCompactor.cpp
+++ b/mailnews/base/src/nsMsgFolderCompactor.cpp
@@ -341,17 +341,17 @@ NS_IMETHODIMP nsFolderCompactState::OnSt
 }
 
 NS_IMETHODIMP nsFolderCompactState::OnStopRunningUrl(nsIURI *url, nsresult status)
 {
   if (m_parsingFolder)
   {
     m_parsingFolder = PR_FALSE;
     if (NS_SUCCEEDED(status))
-      status = Compact(m_folder, m_compactingOfflineFolders, this, m_window);
+      status = Compact(m_folder, m_compactingOfflineFolders, m_listener, m_window);
     else if (m_compactAll)
       CompactNextFolder();
   }
   else if (m_compactAll) // this should be the imap case only
   {
     nsCOMPtr <nsIMsgFolder> prevFolder = do_QueryElementAt(m_folderArray,
                                                            m_folderIndex);
     if (prevFolder)
--- a/mailnews/base/test/unit/test_folderCompact.js
+++ b/mailnews/base/test/unit/test_folderCompact.js
@@ -138,22 +138,39 @@ const gTestArray =
     deleteMessages(gLocalFolder3, [gMsgHdrs[0].hdr], false, false);
   },
   function compactFolder()
   {
     gExpectedFolderSize = calculateFolderSize(gLocalFolder3);
     do_check_neq(gLocalFolder3.expungedBytes, 0);
     gLocalFolder3.compact(urlListener, null);
   },
+  function testDeleteMessages2() {
+    do_check_eq(gExpectedFolderSize, gLocalFolder3.filePath.fileSize);
+    var folder2DB = gLocalFolder2.msgDatabase;
+    gMsgHdrs[0].hdr = folder2DB.getMsgHdrForMessageID(gMsgHdrs[0].ID);
+
+    // Now delete the message
+    deleteMessages(gLocalFolder2, [gMsgHdrs[0].hdr], false, false);
+  },
   function compactAllFolders()
   {
-    do_check_eq(gExpectedFolderSize, gLocalFolder3.filePath.fileSize);
     gExpectedInboxSize = calculateFolderSize(gLocalInboxFolder);
     gExpectedFolder2Size = calculateFolderSize(gLocalFolder2);
     gExpectedFolder3Size = calculateFolderSize(gLocalFolder3);
+    // force expunged bytes count to get cached.
+    let localFolder2ExpungedBytes = gLocalFolder2.expungedBytes;
+    // mark localFolder2 as having an invalid db, and remove it
+    // for good measure.
+    gLocalFolder2.msgDatabase.summaryValid = false;
+    gLocalFolder2.msgDatabase = null;
+    gLocalFolder2.ForceDBClosed();
+    let dbPath = gLocalFolder2.filePath;
+    dbPath.leafName = dbPath.leafName + ".msf";
+    dbPath.remove(false);
     gLocalInboxFolder.compactAll(urlListener, null, true);
   },
   function lastTestCheck()
   {
     do_check_eq(gExpectedInboxSize, gLocalInboxFolder.filePath.fileSize);
     do_check_eq(gExpectedFolder2Size, gLocalFolder2.filePath.fileSize);
     do_check_eq(gExpectedFolder3Size, gLocalFolder3.filePath.fileSize);
     urlListener.OnStopRunningUrl(null, 0);