Bug 732798 - Make sure feed sync (bug 705504) is more robust and handles edge cases without UI loss. r=bienvenu
authoralta88 <alta88@gmail.com>
Mon, 05 Mar 2012 11:10:18 -0700
changeset 11019 4f7dd383534c3ff33a1ed57af246e56e39dc7349
parent 11018 ca6a6449f4220aee3cadd9a87b13410b388c5755
child 11020 53fcee1f9ec3259491f61478e55e77620a0b67c6
push id463
push userbugzilla@standard8.plus.com
push dateTue, 24 Apr 2012 17:34:51 +0000
treeherdercomm-beta@e53588e8f7b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbienvenu
bugs732798, 705504
Bug 732798 - Make sure feed sync (bug 705504) is more robust and handles edge cases without UI loss. r=bienvenu
mailnews/extensions/newsblog/content/utils.js
--- a/mailnews/extensions/newsblog/content/utils.js
+++ b/mailnews/extensions/newsblog/content/utils.js
@@ -402,25 +402,38 @@ function getFeedUrlsInFolder(aFolder)
     feedurls = feedUrlArray.join(kFeedUrlDelimiter);
     if (feedurls) {
       // Do a onetime per folder re-sync of the feeds db here based on the
       // urls in the feedUrl property.
       let ds = getSubscriptionsDS(aFolder.server);
       let resource = rdf.GetResource(aFolder.URI);
       feedUrlArray.forEach(
         function(url) {
-          let id = rdf.GetResource(url);
-          // Get the node for the current folder URI.
-          let node = ds.GetTarget(id, FZ_DESTFOLDER, true);
-          if (node)
-            ds.Change(id, FZ_DESTFOLDER, node, resource);
-          else
-            addFeed(url, resource.name, resource);
-          FeedUtils.log.debug("getFeedUrlsInFolder: sync folder:url - " +
-                              aFolder.name+" : "+url);
+          try {
+            let id = rdf.GetResource(url);
+            // Get the node for the current folder URI.
+            let node = ds.GetTarget(id, FZ_DESTFOLDER, true);
+            if (node)
+            {
+              ds.Change(id, FZ_DESTFOLDER, node, resource);
+              FeedUtils.log.debug("getFeedUrlsInFolder: sync update folder:url - " +
+                                  aFolder.filePath.path+" : "+url);
+            }
+            else
+            {
+              addFeed(url, null, aFolder);
+              FeedUtils.log.debug("getFeedUrlsInFolder: sync add folder:url - " +
+                                  aFolder.filePath.path+" : "+url);
+            }
+          }
+          catch (ex) {
+            FeedUtils.log.debug("getFeedUrlsInFolder: error - " + ex);
+            FeedUtils.log.debug("getFeedUrlsInFolder: sync failed for folder:url - " +
+                                aFolder.filePath.path+" : "+url);
+          }
       });
       ds.QueryInterface(Ci.nsIRDFRemoteDataSource).Flush();
 
       // Set property on folder so we don't come here ever again.
       aFolder.setStringProperty("feedUrl", feedurls);
       aFolder.msgDatabase = null;
 
       return feedUrlArray.length ? feedUrlArray : null;
@@ -429,25 +442,44 @@ function getFeedUrlsInFolder(aFolder)
   else {
     // Forcing a reparse with listener here is the last resort.  Not implemented
     // as it may be unnecessary once feedUrl is property set on folder and not
     // msgDatabase, and if eventually feedUrls are derived from the feeds db
     // directly.
   }
 
   // Get the list from the feeds database.
-  let ds = getSubscriptionsDS(aFolder.server);
-  let enumerator = ds.GetSources(FZ_DESTFOLDER, aFolder, true);
-  while (enumerator.hasMoreElements())
+  try {
+    let ds = getSubscriptionsDS(aFolder.server);
+    let enumerator = ds.GetSources(FZ_DESTFOLDER, aFolder, true);
+    while (enumerator.hasMoreElements())
+    {
+      let containerArc = enumerator.getNext();
+      let uri = containerArc.QueryInterface(Ci.nsIRDFResource).Value;
+      feedUrlArray.push(uri);
+    }
+  }
+  catch(ex)
   {
-    let containerArc = enumerator.getNext();
-    let uri = containerArc.QueryInterface(Components.interfaces.nsIRDFResource).Value;
-    feedUrlArray.push(uri);
+    FeedUtils.log.debug("getFeedUrlsInFolder: feeds db error - " + ex);
+    FeedUtils.log.debug("getFeedUrlsInFolder: feeds db error for folder - " +
+                        aFolder.filePath.path);
   }
 
+  feedurls = feedUrlArray.join(kFeedUrlDelimiter);
+  if (feedurls)
+  {
+    aFolder.setStringProperty("feedUrl", feedurls);
+    FeedUtils.log.debug("getFeedUrlsInFolder: got urls from db, folder:feedUrl - " +
+                        aFolder.filePath.path+" : "+feedurls);
+  }
+  else
+    FeedUtils.log.debug("getFeedUrlsInFolder: no urls from db, folder - " +
+                        aFolder.filePath.path);
+
   return feedUrlArray.length ? feedUrlArray : null;
 }
 
 /**
  * Add or remove urls from feedUrl folder property.  Property is used for
  * access to a folder's feeds in Subscribe dialog and when doing downloadFeed
  * on a folder.  Ensure no dupes.
  *