Bug 1328814 - Don't insist on folder validity when creating an nsIURI object. r=rkent,jorgk
authorJorg K and R Kent James
Mon, 09 Jan 2017 15:59:00 +0100
changeset 20986 f3c3430dddfc3e15ede7d7d98abc1943a0ed1aef
parent 20985 451f4e89b9f5f99a63a96ab742af78886b7c35a4
child 20987 ce82f494b090b9b256122619ce3dc3e069d137df
push id12731
push usermozilla@jorgk.com
push dateTue, 10 Jan 2017 08:04:23 +0000
treeherdercomm-central@d9c51a68b373 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrkent, jorgk
bugs1328814
Bug 1328814 - Don't insist on folder validity when creating an nsIURI object. r=rkent,jorgk
mailnews/imap/src/nsImapService.cpp
--- a/mailnews/imap/src/nsImapService.cpp
+++ b/mailnews/imap/src/nsImapService.cpp
@@ -2574,30 +2574,35 @@ NS_IMETHODIMP nsImapService::NewURI(cons
   NS_ENSURE_TRUE(server, NS_ERROR_FAILURE);
 
   // now try to get the folder in question...
   nsCOMPtr<nsIMsgFolder> rootFolder;
   server->GetRootFolder(getter_AddRefs(rootFolder));
   if (rootFolder && !folderName.IsEmpty())
   {
     nsCOMPtr<nsIMsgFolder> folder;
-    nsCOMPtr<nsIMsgImapMailFolder> imapRoot = do_QueryInterface(rootFolder, &rv);
+    nsCOMPtr<nsIMsgImapMailFolder> imapRoot = do_QueryInterface(rootFolder);
     nsCOMPtr<nsIMsgImapMailFolder> subFolder;
     if (imapRoot)
     {
       imapRoot->FindOnlineSubFolder(folderName, getter_AddRefs(subFolder));
-      folder = do_QueryInterface(subFolder, &rv);
+      folder = do_QueryInterface(subFolder);
     }
-    if (NS_SUCCEEDED(rv))
+
+    // If we can't find the folder, we can still create the URI
+    // in this low-level service. Cloning URIs where the folder
+    // isn't found is common when folders are renamed or moved.
+    // We also ignore return statuses here.
+    if (folder)
     {
       nsCOMPtr<nsIImapMessageSink> msgSink = do_QueryInterface(folder);
-      rv = aImapUrl->SetImapMessageSink(msgSink);
+      (void) aImapUrl->SetImapMessageSink(msgSink);
 
       nsCOMPtr<nsIMsgFolder> msgFolder = do_QueryInterface(folder);
-      rv = SetImapUrlSink(msgFolder, aImapUrl);
+      (void) SetImapUrlSink(msgFolder, aImapUrl);
 
       nsCString messageIdString;
       aImapUrl->GetListOfMessageIds(messageIdString);
       if (!messageIdString.IsEmpty())
       {
         bool useLocalCache = false;
         msgFolder->HasMsgOffline(atoi(messageIdString.get()), &useLocalCache);
         mailnewsUrl->SetMsgIsInLocalCache(useLocalCache);