Bug 854162 - Fix autosync not correctly detecting message offline status. r+a=Standard8
authorDavid Lechner <david@lechnology.com>
Sat, 23 Mar 2013 23:28:52 -0500
changeset 14960 421dd14083af9203e5905d9f2a28f854054bc7ab
parent 14959 19386d8aa4997db97a8a75ec3bc35137d5f1be9d
child 14961 5705670f1e115a88596d61d9ec84a7955f907ad0
push id867
push userbugzilla@standard8.plus.com
push dateMon, 01 Apr 2013 20:44:27 +0000
treeherdercomm-beta@797726b8d244 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs854162
Bug 854162 - Fix autosync not correctly detecting message offline status. r+a=Standard8
mailnews/imap/src/nsAutoSyncState.cpp
--- a/mailnews/imap/src/nsAutoSyncState.cpp
+++ b/mailnews/imap/src/nsAutoSyncState.cpp
@@ -261,19 +261,19 @@ NS_IMETHODIMP nsAutoSyncState::GetNextGr
         nsCOMPtr<nsIMsgDBHdr> qhdr;
         database->GetMsgHdrForKey(mDownloadQ[idx], getter_AddRefs(qhdr));
         if(!qhdr)
           continue; //maybe deleted, skip it!
 
         // ensure that we don't have this message body offline already,
         // possible if the user explicitly selects this message prior
         // to auto-sync kicks in
-        uint32_t msgFlags = 0;
-        qhdr->GetFlags(&msgFlags);
-        if (msgFlags & nsMsgMessageFlags::Offline)
+        bool hasMessageOffline;
+        folder->HasMsgOffline(mDownloadQ[idx], &hasMessageOffline);
+        if (hasMessageOffline)
           continue;
 
         // this check point allows msg strategy function
         // to do last minute decisions based on the current
         // state of TB such as the size of the message store etc.
         if (msgStrategy)
         {
           bool excluded = false;
@@ -345,26 +345,20 @@ NS_IMETHODIMP nsAutoSyncState::ProcessEx
   }
 
   // process the existing headers and find the messages not downloaded yet
   uint32_t lastIdx = mProcessPointer;
   nsTArray<nsMsgKey> msgKeys;
   uint32_t keyCount = mExistingHeadersQ.Length();
   for (; mProcessPointer < (lastIdx + aNumOfHdrsToProcess) && mProcessPointer < keyCount; mProcessPointer++)
   {
-    nsCOMPtr<nsIMsgDBHdr> hdr;
-    rv = database->GetMsgHdrForKey(mExistingHeadersQ[mProcessPointer], getter_AddRefs(hdr));
-    if (hdr)
-    {
-      uint32_t msgFlags = 0;
-      hdr->GetFlags(&msgFlags);
-
-      if (!(msgFlags & nsMsgMessageFlags::Offline))
-        msgKeys.AppendElement(mExistingHeadersQ[mProcessPointer]);
-    }
+    bool hasMessageOffline;
+    folder->HasMsgOffline(mExistingHeadersQ[mProcessPointer], &hasMessageOffline);
+    if (!hasMessageOffline)
+      msgKeys.AppendElement(mExistingHeadersQ[mProcessPointer]);
   }
   if (!msgKeys.IsEmpty())
   {
     nsCString folderName;
     folder->GetURI(folderName);
     PR_LOG(gAutoSyncLog, PR_LOG_DEBUG,
           ("%d messages will be added into the download q of folder %s\n",
             msgKeys.Length(), folderName.get()));