Bug 774351 - If msf database is missing for a folder on a mouseover, do not show a needless exception. r=mkmelin
authoraceman <acelists@atlas.sk>
Wed, 30 Oct 2013 08:46:27 -0400
changeset 16848 4f902dd8fa8dbda53279bd09d0248068b693b430
parent 16847 efb6b395ade27f37e8a538f76cbb4c675b7297f9
child 16849 48dd85f8ce1bfd005ed480351a1e0a94ac06a485
push id1074
push userbugzilla@standard8.plus.com
push dateMon, 03 Feb 2014 22:47:23 +0000
treeherdercomm-beta@6b791b5369ed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs774351
Bug 774351 - If msf database is missing for a folder on a mouseover, do not show a needless exception. r=mkmelin
mail/base/content/mailWidgets.xml
--- a/mail/base/content/mailWidgets.xml
+++ b/mail/base/content/mailWidgets.xml
@@ -2411,48 +2411,65 @@
       <property name="hasMessages" readonly="true" onget="return document.getAnonymousNodes(this)[0].hasChildNodes();"/>
       <method name="parseFolder">
         <parameter name="aFolder"/>
         <parameter name="aUrlListener"/>
         <parameter name="aOutAsync"/>
         <body>
           <![CDATA[
             // skip servers, Trash, Junk folders and newsgroups
-
             if (!aFolder || aFolder.isServer || !aFolder.hasNewMessages ||
                 aFolder.getFlag(Components.interfaces.nsMsgFolderFlags.Junk) ||
                 aFolder.getFlag(Components.interfaces.nsMsgFolderFlags.Trash) ||
                 (aFolder.server instanceof Components.interfaces.nsINntpIncomingServer))
               return false;
             var showPreviewText = this.Services.prefs.getBoolPref("mail.biff.alert.show_preview");
-            var folderArray = new Array;
+            let folderArray = [];
+            let msgDatabase;
+            try {
+              msgDatabase = aFolder.msgDatabase;
+            } catch(e) {
+              // The database for this folder may be missing (e.g. outdated/missing .msf),
+              // so just skip this folder.
+              return false;
+            }
+
             if (aFolder.flags & Components.interfaces.nsMsgFolderFlags.Virtual)
             {
-              var dbFolderInfo = aFolder.msgDatabase.dBFolderInfo;
+              let dbFolderInfo = msgDatabase.dBFolderInfo;
               var srchFolderUri = dbFolderInfo.getCharProperty("searchFolderUri");
               var srchFolderUriArray = srchFolderUri.split('|');
               var foldersAdded = 0;
               var RDF = Components.classes['@mozilla.org/rdf/rdf-service;1']
                                   .getService(Components.interfaces.nsIRDFService);
               for (var i in srchFolderUriArray)
               {
                 var realFolder = RDF.GetResource(srchFolderUriArray[i])
                                     .QueryInterface(Components.interfaces.nsIMsgFolder);
                 if (!realFolder.isServer)
                   folderArray[foldersAdded++] = realFolder;
               }
             }
-            else
+            else {
               folderArray[0] = aFolder;
+            }
+
             var foundNewMsg = false;
             for (var folderIndex = 0; folderIndex < folderArray.length; folderIndex++)
             {
               aFolder = folderArray[folderIndex];
               // now get the database
-              var msgDatabase = aFolder.msgDatabase;
+              try {
+                msgDatabase = aFolder.msgDatabase;
+              } catch(e) {
+                // The database for this folder may be missing (e.g. outdated/missing .msf),
+                // then just skip this folder.
+                continue;
+              }
+
               aFolder.msgDatabase = null;
               var msgKeys = {};
               var numMsgKeys = {};
               msgDatabase.getNewList(numMsgKeys, msgKeys);
 
               if (!numMsgKeys.value)
                 continue;