Bug 731702 - Ensure the feeds database is cleaned up on failed feeds subscriptions. r=dbienvenu
authoralta88 <alta88@gmail.com>
Wed, 29 Feb 2012 12:28:17 -0700
changeset 11010 82b9318911d5c1fa7faf08989918d3a5c0fe465f
parent 11009 ef7d32dbdb470dfc1998db3180fb758a810b6e16
child 11011 86ad735b5ddfa1e555a6cd402215d1d125a2a1c9
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)
reviewersdbienvenu
bugs731702
Bug 731702 - Ensure the feeds database is cleaned up on failed feeds subscriptions. r=dbienvenu
mailnews/extensions/newsblog/content/utils.js
--- a/mailnews/extensions/newsblog/content/utils.js
+++ b/mailnews/extensions/newsblog/content/utils.js
@@ -89,34 +89,48 @@ var FeedUtils = {
               aSubscribeMode ? "subscribe-validating-feed" :
                                "newsblog-getNewMsgsCheck"));
         }
       }
     },
 
     downloaded: function(feed, aErrorCode)
     {
-      FeedUtils.log.debug("downloaded: feed:errorCode - " +
+      FeedUtils.log.debug("downloaded: "+
+                          (this.mSubscribeMode ? "Subscribe " : "Update ") +
+                          "feed:errorCode - " +
                           feed.name+" : "+aErrorCode);
-      if (this.mSubscribeMode && aErrorCode == FeedUtils.kNewsBlogSuccess)
+      if (this.mSubscribeMode)
       {
-        // If we get here we should always have a folder by now, either in
-        // feed.folder or FeedItems created the folder for us.
-        updateFolderFeedUrl(feed.folder, feed.url, false);
+        if (aErrorCode == FeedUtils.kNewsBlogSuccess)
+        {
+          // If we get here we should always have a folder by now, either in
+          // feed.folder or FeedItems created the folder for us.
+          updateFolderFeedUrl(feed.folder, feed.url, false);
+
+          // Add feed just adds the feed to the subscription UI and flushes the
+          // datasource.
+          addFeed(feed.url, feed.name, feed.folder);
 
-        // Add feed just adds the feed to the subscription UI and flushes the
-        // datasource.
-        addFeed(feed.url, feed.name, feed.folder);
+          // Nice touch: select the folder that now contains the newly subscribed
+          // feed.  This is particularly nice if we just finished subscribing
+          // to a feed URL that the operating system gave us.
+          this.mMsgWindow.windowCommands.selectFolder(feed.folder.URI);
+        }
+        else
+        {
+          // Non success.  Remove intermediate traces from the feeds database.
+          if (feed && feed.url && feed.server)
+            deleteFeed(rdf.GetResource(feed.url),
+                       feed.server,
+                       feed.server.rootFolder);
+        }
+      }
 
-        // Nice touch: select the folder that now contains the newly subscribed
-        // feed.  This is particularly nice if we just finished subscribing
-        // to a feed URL that the operating system gave us.
-        this.mMsgWindow.windowCommands.selectFolder(feed.folder.URI);
-      }
-      else if (feed.folder && aErrorCode != FeedUtils.kNewsBlogFeedIsBusy)
+      if (feed.folder && aErrorCode != FeedUtils.kNewsBlogFeedIsBusy)
         // Free msgDatabase after new mail biff is set; if busy let the next
         // result do the freeing.  Otherwise new messages won't be indicated.
         feed.folder.msgDatabase = null;
 
       if (this.mStatusFeedback)
       {
         if (aErrorCode == FeedUtils.kNewsBlogNoNewItems)
           this.mStatusFeedback.showStatusString(