Bug 1633205 - Pay attention to HasRe flag in nsImapMailFolder::SetPendingAttributes() and nsMsgLocalMailFolder::EndCopy(). r=benc a=wsmwk
authorJorg K <jorgk@jorgk.com>
Sun, 26 Apr 2020 11:13:51 +0200
changeset 36187 e07c55e1519277df2cab5d92787c517256391354
parent 36186 daeb6f6b69b015e9167eb21e3ffddb71b9a7b36f
child 36188 a6ffe45d0fc09fffa87fce6314f492a521883e52
push id108
push userthunderbird@calypsoblue.org
push dateMon, 01 Jun 2020 19:26:03 +0000
treeherdercomm-esr68@2993d616ef7d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbenc, wsmwk
bugs1633205
Bug 1633205 - Pay attention to HasRe flag in nsImapMailFolder::SetPendingAttributes() and nsMsgLocalMailFolder::EndCopy(). r=benc a=wsmwk
mailnews/imap/src/nsImapMailFolder.cpp
mailnews/local/src/nsLocalMailFolder.cpp
--- a/mailnews/imap/src/nsImapMailFolder.cpp
+++ b/mailnews/imap/src/nsImapMailFolder.cpp
@@ -6829,33 +6829,43 @@ void nsImapMailFolder::SetPendingAttribu
 
         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
@@ -2211,24 +2211,27 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndC
       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