fix bug 661774, handle error fetching all imap flags, don't throw away hdr cache on such errors, r=neil
authorDavid Bienvenu <bienvenu@nventure.com>
Fri, 01 Jul 2011 13:34:07 -0700
changeset 8253 e307f0c7a8f1e456b18a41542f30eae69f9f0bfb
parent 8252 53f62c5da9e2c68247c719646e67cb6d4cb3c648
child 8254 c319bf1f086a9a6a0adda661bd8441b91f641def
push id84
push userbugzilla@standard8.plus.com
push dateTue, 16 Aug 2011 21:25:04 +0000
treeherdercomm-beta@6970c86be3cd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersneil
bugs661774
fix bug 661774, handle error fetching all imap flags, don't throw away hdr cache on such errors, r=neil
mailnews/imap/src/nsImapProtocol.cpp
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -4028,23 +4028,20 @@ void nsImapProtocol::AbortMessageDownLoa
 
 
 void nsImapProtocol::ProcessMailboxUpdate(PRBool handlePossibleUndo)
 {
   if (DeathSignalReceived())
     return;
 
   // Update quota information
-  if (!DeathSignalReceived())
-  {
-    char *boxName;
-    GetSelectedMailboxName(&boxName);
-    GetQuotaDataIfSupported(boxName);
-    PR_Free(boxName);
-  }
+  char *boxName;
+  GetSelectedMailboxName(&boxName);
+  GetQuotaDataIfSupported(boxName);
+  PR_Free(boxName);
 
   // fetch the flags and uids of all existing messages or new ones
   if (!DeathSignalReceived() && GetServerStateParser().NumberOfMessages())
   {
     if (handlePossibleUndo)
     {
       // undo any delete flags we may have asked to
       nsCString undoIdsStr;
@@ -4095,17 +4092,17 @@ void nsImapProtocol::ProcessMailboxUpdat
       if (!needFullFolderSync && !GetShowDeletedMessages() && UseCondStore())
         PR_snprintf(fetchModifier, sizeof(fetchModifier), " (CHANGEDSINCE %llu)",
                     mFolderLastModSeq);
       else
         m_flagState->SetPartialUIDFetch(PR_FALSE);
 
       FetchMessage(idsToFetch, kFlags, fetchModifier);
       // lets see if we should expunge during a full sync of flags.
-      if (!DeathSignalReceived()) 
+      if (GetServerStateParser().LastCommandSuccessful())
       {
         // if we did a CHANGEDSINCE fetch, do a sanity check on the msg counts
         // to see if some other client may have done an expunge.
         if (m_flagState->GetPartialUIDFetch())
         {
           if (m_flagState->NumberOfDeletedMessages() + 
               mFolderTotalMsgCount != GetServerStateParser().NumberOfMessages())
           {
@@ -4138,38 +4135,38 @@ void nsImapProtocol::ProcessMailboxUpdat
       if (UseCondStore() && !highestRecordedUID)
         highestRecordedUID = mFolderHighestUID;
 
       AppendUid(fetchStr, highestRecordedUID + 1);
       fetchStr.Append(":*");
       FetchMessage(fetchStr, kFlags);      // only new messages please
     }
   }
-  else if (!DeathSignalReceived())
+  else if (GetServerStateParser().LastCommandSuccessful())
   {
     GetServerStateParser().ResetFlagInfo();
     // the flag state is empty, but not partial.
     m_flagState->SetPartialUIDFetch(PR_FALSE);
   }
 
-  if (!DeathSignalReceived())
+  if (GetServerStateParser().LastCommandSuccessful())
   {
     nsImapAction imapAction;
     nsresult res = m_runningUrl->GetImapAction(&imapAction);
     if (NS_SUCCEEDED(res) && imapAction == nsIImapUrl::nsImapLiteSelectFolder)
       return;
   }
 
   PRBool entered_waitForBodyIdsMonitor = PR_FALSE;
 
   PRUint32 *msgIdList = nsnull;
   PRUint32 msgCount = 0;
 
   nsImapMailboxSpec *new_spec = GetServerStateParser().CreateCurrentMailboxSpec();
-  if (new_spec && !DeathSignalReceived())
+  if (new_spec && GetServerStateParser().LastCommandSuccessful())
   {
     nsImapAction imapAction;
     nsresult res = m_runningUrl->GetImapAction(&imapAction);
     if (NS_SUCCEEDED(res) && imapAction == nsIImapUrl::nsImapExpungeFolder)
       new_spec->mBoxFlags |= kJustExpunged;
     m_waitForBodyIdsMonitor.Enter();
     entered_waitForBodyIdsMonitor = PR_TRUE;
 
@@ -4184,17 +4181,17 @@ void nsImapProtocol::ProcessMailboxUpdat
       // We're going to be re-running this url if there are more headers.
       if (more)
         m_runningUrl->SetRerunningUrl(PR_TRUE);
     }
   }
   else if (!new_spec)
     HandleMemoryFailure();
 
-  if (!DeathSignalReceived())
+  if (GetServerStateParser().LastCommandSuccessful())
   {
     if (entered_waitForBodyIdsMonitor)
       m_waitForBodyIdsMonitor.Exit();
 
     if (msgIdList && !DeathSignalReceived() && GetServerStateParser().LastCommandSuccessful())
     {
       FolderHeaderDump(msgIdList, msgCount);
       NS_Free( msgIdList);
@@ -4202,33 +4199,33 @@ void nsImapProtocol::ProcessMailboxUpdat
     HeaderFetchCompleted();
       // this might be bogus, how are we going to do pane notification and stuff when we fetch bodies without
       // headers!
   }
   else if (entered_waitForBodyIdsMonitor) // need to exit this monitor if death signal received
     m_waitForBodyIdsMonitor.Exit();
 
   // wait for a list of bodies to fetch.
-  if (!DeathSignalReceived() && GetServerStateParser().LastCommandSuccessful())
+  if (GetServerStateParser().LastCommandSuccessful())
   {
     WaitForPotentialListOfBodysToFetch(&msgIdList, msgCount);
-    if ( msgCount && !DeathSignalReceived() && GetServerStateParser().LastCommandSuccessful())
+    if ( msgCount && GetServerStateParser().LastCommandSuccessful())
     {
       // Tell the url that it should store the msg fetch results offline,
       // while we're dumping the messages, and then restore the setting.
       PRBool wasStoringOffline;
       m_runningUrl->GetStoreResultsOffline(&wasStoringOffline);
       m_runningUrl->SetStoreResultsOffline(PR_TRUE);
       m_progressIndex = 0;
       m_progressCount = msgCount;
       FolderMsgDump(msgIdList, msgCount, kEveryThingRFC822Peek);
       m_runningUrl->SetStoreResultsOffline(wasStoringOffline);
     }
   }
-  if (DeathSignalReceived())
+  if (!GetServerStateParser().LastCommandSuccessful())
     GetServerStateParser().ResetFlagInfo();
 
   NS_IF_RELEASE(new_spec);
 }
 
 void nsImapProtocol::FolderHeaderDump(PRUint32 *msgUids, PRUint32 msgCount)
 {
   FolderMsgDump(msgUids, msgCount, kHeadersRFC822andUid);