Bug 1633205 - Pay attention to HasRe flag in nsImapMailFolder::SetPendingAttributes() and nsMsgLocalMailFolder::EndCopy(). r=benc DONTBUILD
authorJorg K <jorgk@jorgk.com>
Tue, 28 Apr 2020 12:32:19 +0200
changeset 38059 fd16d22d04fa421ab6552ba8e6b7bde56235e9d4
parent 38058 263dae2cae3fb036f47bdf11fcb567d50b746066
child 38060 ed17a22ae3d993d170302dadc067168391d3bb30
push id2595
push userclokep@gmail.com
push dateMon, 04 May 2020 19:02:04 +0000
treeherdercomm-beta@f53913797371 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbenc
bugs1633205
Bug 1633205 - Pay attention to HasRe flag in nsImapMailFolder::SetPendingAttributes() and nsMsgLocalMailFolder::EndCopy(). r=benc DONTBUILD
mailnews/imap/src/nsImapMailFolder.cpp
mailnews/local/src/nsLocalMailFolder.cpp
--- a/mailnews/imap/src/nsImapMailFolder.cpp
+++ b/mailnews/imap/src/nsImapMailFolder.cpp
@@ -6913,33 +6913,42 @@ void nsImapMailFolder::SetPendingAttribu
       if (dontPreserveEx.Find(propertyEx) != kNotFound) continue;
 
       nsCString sourceString;
       msgDBHdr->GetStringProperty(property.get(), getter_Copies(sourceString));
       mDatabase->SetAttributeOnPendingHdr(msgDBHdr, property.get(),
                                           sourceString.get());
     }
 
+    // Carry over HasRe flag.
+    uint32_t flags;
+    uint32_t storeFlags = 0;
+    msgDBHdr->GetFlags(&flags);
+    if (flags & nsMsgMessageFlags::HasRe) {
+      storeFlags = nsMsgMessageFlags::HasRe;
+      mDatabase->SetUint32AttributeOnPendingHdr(msgDBHdr, "flags", storeFlags);
+    }
+
     uint32_t messageSize;
     uint64_t messageOffset;
     nsCString storeToken;
     msgDBHdr->GetMessageOffset(&messageOffset);
     msgDBHdr->GetOfflineMessageSize(&messageSize);
     msgDBHdr->GetStringProperty("storeToken", getter_Copies(storeToken));
     if (messageSize) {
       mDatabase->SetUint32AttributeOnPendingHdr(msgDBHdr, "offlineMsgSize",
                                                 messageSize);
       mDatabase->SetUint64AttributeOnPendingHdr(msgDBHdr, "msgOffset",
                                                 messageOffset);
       // Not always setting "flags" attribute to nsMsgMessageFlags::Offline
       // here because it can cause missing parts (inline or attachments)
       // when messages are moved or copied manually or by filter action.
       if (aSetOffline)
-        mDatabase->SetUint32AttributeOnPendingHdr(msgDBHdr, "flags",
-                                                  nsMsgMessageFlags::Offline);
+        mDatabase->SetUint32AttributeOnPendingHdr(
+            msgDBHdr, "flags", storeFlags | nsMsgMessageFlags::Offline);
       mDatabase->SetAttributeOnPendingHdr(msgDBHdr, "storeToken",
                                           storeToken.get());
     }
     nsMsgPriorityValue priority;
     msgDBHdr->GetPriority(&priority);
     if (priority != 0) {
       nsAutoCString priorityStr;
       priorityStr.AppendInt(priority);
--- a/mailnews/local/src/nsLocalMailFolder.cpp
+++ b/mailnews/local/src/nsLocalMailFolder.cpp
@@ -2243,24 +2243,27 @@ nsMsgLocalMailFolder::EndCopy(bool aCopy
       mCopyState->m_newHdr = newHdr;
       if (NS_SUCCEEDED(result) && newHdr) {
         // Copy message metadata.
         if (mCopyState->m_message) {
           // Propagate the new flag on an imap to local folder filter action
           // Flags may get changed when deleting the original source message in
           // IMAP. We have a copy of the original flags, but parseMsgState has
           // already tried to decide what those flags should be. Who to believe?
-          // Let's only deal here with the flags that might get changed, Read
-          // and New, and trust upstream code for everything else.
-          uint32_t readAndNew =
-              nsMsgMessageFlags::New | nsMsgMessageFlags::Read;
+          // Let's deal here with the flags that might get changed, Read and
+          // New, and trust upstream code for everything else. However,
+          // we need to carry over HasRe since the subject is copied over
+          // from the original.
+          uint32_t carryOver = nsMsgMessageFlags::New |
+                               nsMsgMessageFlags::Read |
+                               nsMsgMessageFlags::HasRe;
           uint32_t newFlags;
           newHdr->GetFlags(&newFlags);
-          newHdr->SetFlags((newFlags & ~readAndNew) |
-                           ((mCopyState->m_flags) & readAndNew));
+          newHdr->SetFlags((newFlags & ~carryOver) |
+                           ((mCopyState->m_flags) & carryOver));
 
           // Copy other message properties.
           CopyPropertiesToMsgHdr(newHdr, mCopyState->m_message,
                                  mCopyState->m_isMove);
         }
         msgDb->AddNewHdrToDB(newHdr, true);
         if (localUndoTxn) {
           // ** jt - recording the message size for possible undo use; the