diff --git a/services/sync/modules/engines.js b/services/sync/modules/engines.js index 86ef2c0f2e7..434fba5bc71 100644 --- a/services/sync/modules/engines.js +++ b/services/sync/modules/engines.js @@ -347,7 +347,7 @@ SyncEngine.prototype = { } }, - _changeRecordID: function SyncEngine__changeRecordID(oldID, newID) { + _changeItemID: function SyncEngine__changeItemID(oldID, newID) { let self = yield; throw "_changeRecordID must be overridden in a subclass"; }, @@ -390,6 +390,8 @@ SyncEngine.prototype = { meta.generateIV(); yield meta.addUnwrappedKey(self.cb, pubkey, symkey); yield meta.put(self.cb); + + this._tracker.disable(); } }, @@ -522,14 +524,12 @@ SyncEngine.prototype = { let self = yield; if (this.incoming.length) { this._log.debug("Applying server changes"); - this._tracker.disable(); let inc; while ((inc = this.incoming.shift())) { yield this._store.applyIncoming(self.cb, inc); if (inc.modified > this.lastSync) this.lastSync = inc.modified; } - this._tracker.enable(); } }, @@ -557,26 +557,33 @@ SyncEngine.prototype = { let self = yield; this._log.debug("Finishing up sync"); this._tracker.resetScore(); + this._tracker.enable(); }, _sync: function SyncEngine__sync() { let self = yield; - yield this._syncStartup.async(this, self.cb); + try { + yield this._syncStartup.async(this, self.cb); - // Populate incoming and outgoing queues - yield this._generateOutgoing.async(this, self.cb); - yield this._fetchIncoming.async(this, self.cb); + // Populate incoming and outgoing queues + yield this._generateOutgoing.async(this, self.cb); + yield this._fetchIncoming.async(this, self.cb); - // Decrypt and sort incoming records, then reconcile - yield this._processIncoming.async(this, self.cb); - yield this._reconcile.async(this, self.cb); + // Decrypt and sort incoming records, then reconcile + yield this._processIncoming.async(this, self.cb); + yield this._reconcile.async(this, self.cb); - // Apply incoming records, upload outgoing records - yield this._applyIncoming.async(this, self.cb); - yield this._uploadOutgoing.async(this, self.cb); - - yield this._syncFinish.async(this, self.cb); + // Apply incoming records, upload outgoing records + yield this._applyIncoming.async(this, self.cb); + yield this._uploadOutgoing.async(this, self.cb); + } + catch (e) { + throw e; + } + finally { + yield this._syncFinish.async(this, self.cb); + } }, _resetServer: function SyncEngine__resetServer() { diff --git a/services/sync/modules/engines/bookmarks.js b/services/sync/modules/engines/bookmarks.js index 3be9fe9f8a7..583e7741548 100644 --- a/services/sync/modules/engines/bookmarks.js +++ b/services/sync/modules/engines/bookmarks.js @@ -785,9 +785,9 @@ BookmarksEngine.prototype = { } }, - _changeRecordID: function BmkEngine__changeRecordID(oldID, newID) { + _changeItemID: function BmkEngine__changeRecordID(oldID, newID) { let self = yield; - yield this._store._changeRecordID.async(this._store, self.cb, oldID, newID); + yield this._store._changeItemID.async(this._store, self.cb, oldID, newID); } // XXX for sharing, will need to re-add code to get new shares before syncing,