Bug 1629204 - Avoid performing folder discovery during shutdown. r=mkmelin
authorBen Campbell <benc@thunderbird.net>
Wed, 29 Apr 2020 13:34:08 +0300
changeset 38075 d7148a4246747373d1a49d70c55d813bd85d87e5
parent 38074 62005c97509ce7ffb9f8c00f1d4d6f7d6486a033
child 38076 7853102282e6bc50b8a2317e86b5185b0c5c250d
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)
reviewersmkmelin
bugs1629204
Bug 1629204 - Avoid performing folder discovery during shutdown. r=mkmelin
mailnews/base/util/nsMsgDBFolder.cpp
--- a/mailnews/base/util/nsMsgDBFolder.cpp
+++ b/mailnews/base/util/nsMsgDBFolder.cpp
@@ -1291,19 +1291,22 @@ NS_IMETHODIMP nsMsgDBFolder::WriteToFold
                                         getter_AddRefs(cacheElement));
       if (NS_SUCCEEDED(rv) && cacheElement)
         rv = WriteToFolderCacheElem(cacheElement);
     }
   }
 
   if (!deep) return rv;
 
+  // NOTE: We must use mSubFolders directly, as GetSubFolders() can cause folder
+  // discovery (creation), which we don't need or want here. See bug 1629204.
   nsCOMPtr<nsISimpleEnumerator> enumerator;
-  rv = GetSubFolders(getter_AddRefs(enumerator));
-  if (NS_FAILED(rv)) return rv;
+  rv = NS_NewArrayEnumerator(getter_AddRefs(enumerator), mSubFolders,
+                             NS_GET_IID(nsIMsgFolder));
+  NS_ENSURE_SUCCESS(rv, rv);
 
   bool hasMore;
   while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore) {
     nsCOMPtr<nsISupports> item;
     enumerator->GetNext(getter_AddRefs(item));
 
     nsCOMPtr<nsIMsgFolder> msgFolder(do_QueryInterface(item));
     if (!msgFolder) continue;