Bug 1554424 - do not periodically load Inbox folder for account that has no periodic filters defined. r=mkmelin
authoraceman <acelists@atlas.sk>
Sun, 26 May 2019 13:38:00 +0200
changeset 35694 19ec36793dc973a57edaa762922b204647467855
parent 35693 066da1c827a51483d07a8b64b09497fcc320b812
child 35695 2249b3ca338c6c3e0bc1643240ba28cd80e81f6c
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
reviewersmkmelin
bugs1554424
Bug 1554424 - do not periodically load Inbox folder for account that has no periodic filters defined. r=mkmelin
mailnews/base/search/src/PeriodicFilterManager.jsm
--- a/mailnews/base/search/src/PeriodicFilterManager.jsm
+++ b/mailnews/base/search/src/PeriodicFilterManager.jsm
@@ -82,21 +82,19 @@ var PeriodicFilterManager = {
     for (let server of fixIterator(servers, Ci.nsIMsgIncomingServer)) {
       if (!server.canHaveFilters)
         continue;
       if (server.getIntValue("nextFilterTime") > nowTime)
         continue;
       if (server.serverBusy)
         continue;
 
+      // Schedule next time this account's filters should be run.
       server.setIntValue("nextFilterTime", nowTime + this.getServerPeriod(server));
       server.setIntValue("lastFilterTime", nowTime);
-      let foldersToFilter = server.rootFolder.getFoldersWithFlags(Ci.nsMsgFolderFlags.Inbox);
-      if (!foldersToFilter.length)
-        continue;
 
       // Build a temporary list of periodic filters.
       // XXX TODO: make applyFiltersToFolders() take a filterType instead (bug 1551043).
       let curFilterList = server.getFilterList(null);
       let tempFilterList = MailServices.filters.getTempFilterList(server.rootFolder);
       let numFilters = curFilterList.filterCount;
       tempFilterList.logStream = curFilterList.logStream;
       tempFilterList.loggingEnabled = curFilterList.loggingEnabled;
@@ -105,16 +103,22 @@ var PeriodicFilterManager = {
         let curFilter = curFilterList.getFilterAt(i);
         // Only add enabled, UI visible filters that are of the Periodic type.
         if (curFilter.enabled && !curFilter.temporary &&
             (curFilter.filterType & Ci.nsMsgFilterType.Periodic)) {
           tempFilterList.insertFilterAt(newFilterIndex, curFilter);
           newFilterIndex++;
         }
       }
+      if (newFilterIndex == 0)
+        continue;
+      let foldersToFilter = server.rootFolder.getFoldersWithFlags(Ci.nsMsgFolderFlags.Inbox);
+      if (foldersToFilter.length == 0)
+        continue;
+
       log.debug("PeriodicFilterManager apply periodic filters to server " + server.prettyName);
       MailServices.filters.applyFiltersToFolders(tempFilterList, foldersToFilter, null);
     }
     this._running = false;
   },
 
   /**
    * Gets the periodic filter interval for the given server.