diff --git a/services/sync/modules/engines.js b/services/sync/modules/engines.js index 36f3209d30a..8fd29ae0cdf 100644 --- a/services/sync/modules/engines.js +++ b/services/sync/modules/engines.js @@ -331,6 +331,10 @@ SyncEngine.prototype = { this._toFetch = o)); }, + _makeUploadColl: function _makeUploadColl() { + return new Collection(this.engineURL); + }, + // Create a new record by querying the store, and add the engine metadata _createRecord: function SyncEngine__createRecord(id) { return this._store.createRecord(id, this.cryptoMetaURL); @@ -580,7 +584,7 @@ SyncEngine.prototype = { this._log.debug("Preparing " + outnum + " outgoing records"); // collection we'll upload - let up = new Collection(this.engineURL); + let up = this._makeUploadColl(); let count = 0; // Upload what we've got so far in the collection diff --git a/services/sync/modules/engines/history.js b/services/sync/modules/engines/history.js index 237aa14d3be..ef7ddc740a8 100644 --- a/services/sync/modules/engines/history.js +++ b/services/sync/modules/engines/history.js @@ -87,6 +87,19 @@ HistoryEngine.prototype = { _findDupe: function _findDupe(item) { return GUIDForUri(item.histUri); + }, + + _makeUploadColl: function _makeUploadColl() { + let coll = SyncEngine.prototype._makeUploadColl.call(this); + let origPush = coll.pushData; + + // Only push the data for upload if it has more than 1 visit + coll.pushData = function(data) { + if (data._visitCount > 1) + origPush.call(coll, data); + }; + + return coll; } }; @@ -255,6 +268,10 @@ HistoryStore.prototype = { record.title = foo.title; record.visits = this._getVisits(record.histUri); record.encryption = cryptoMetaURL; + + // XXX Add a value to the object so that pushData can read out, but we end + // up encrypting the data before calling pushData :( + record._visitCount = record.visits.length; } else record.deleted = true;