Bug 1006360 - prevent failures backing up bookmarks from stopping sync completing. r=rnewman, a=sylvestre
authorMark Hammond <mhammond@skippinet.com.au>
Mon, 12 May 2014 09:26:31 +1000
changeset 192245 d202bb3a79cf
parent 192244 d7abd8044d61
child 192246 7d945895a6d9
push id3541
push usermhammond@skippinet.com.au
push date2014-05-11 23:27 +0000
treeherdermozilla-beta@d202bb3a79cf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman, sylvestre
bugs1006360
milestone30.0
Bug 1006360 - prevent failures backing up bookmarks from stopping sync completing. r=rnewman, a=sylvestre
services/sync/modules/engines/bookmarks.js
--- a/services/sync/modules/engines/bookmarks.js
+++ b/services/sync/modules/engines/bookmarks.js
@@ -344,41 +344,52 @@ BookmarksEngine.prototype = {
 
   _syncStartup: function _syncStart() {
     SyncEngine.prototype._syncStartup.call(this);
 
     let cb = Async.makeSpinningCallback();
     Task.spawn(function() {
       // For first-syncs, make a backup for the user to restore
       if (this.lastSync == 0) {
+        this._log.debug("Bookmarks backup starting.");
         yield PlacesBackups.create(null, true);
+        this._log.debug("Bookmarks backup done.");
       }
+    }.bind(this)).then(
+      cb, ex => {
+        // Failure to create a backup is somewhat bad, but probably not bad
+        // enough to prevent syncing of bookmarks - so just log the error and
+        // continue.
+        this._log.warn("Got exception \"" + Utils.exceptionStr(ex) +
+                       "\" backing up bookmarks, but continuing with sync.");
+        cb();
+      }
+    );
 
-      this.__defineGetter__("_guidMap", function() {
-        // Create a mapping of folder titles and separator positions to GUID.
-        // We do this lazily so that we don't do any work unless we reconcile
-        // incoming items.
-        let guidMap;
-        try {
-          guidMap = this._buildGUIDMap();
-        } catch (ex) {
-          this._log.warn("Got exception \"" + Utils.exceptionStr(ex) +
-                         "\" building GUID map." +
-                         " Skipping all other incoming items.");
-          throw {code: Engine.prototype.eEngineAbortApplyIncoming,
-                 cause: ex};
-        }
-        delete this._guidMap;
-        return this._guidMap = guidMap;
-      });
+    cb.wait();
 
-      this._store._childrenToOrder = {};
-      cb();
-    }.bind(this));
-    cb.wait();
+    this.__defineGetter__("_guidMap", function() {
+      // Create a mapping of folder titles and separator positions to GUID.
+      // We do this lazily so that we don't do any work unless we reconcile
+      // incoming items.
+      let guidMap;
+      try {
+        guidMap = this._buildGUIDMap();
+      } catch (ex) {
+        this._log.warn("Got exception \"" + Utils.exceptionStr(ex) +
+                       "\" building GUID map." +
+                       " Skipping all other incoming items.");
+        throw {code: Engine.prototype.eEngineAbortApplyIncoming,
+               cause: ex};
+      }
+      delete this._guidMap;
+      return this._guidMap = guidMap;
+    });
+
+    this._store._childrenToOrder = {};
   },
 
   _processIncoming: function (newitems) {
     try {
       SyncEngine.prototype._processIncoming.call(this, newitems);
     } finally {
       // Reorder children.
       this._tracker.ignoreAll = true;