From 650316bd7383a6c148076d8faca21944b82034b4 Mon Sep 17 00:00:00 2001 From: Edward Lee Date: Fri, 5 Mar 2010 14:46:48 -0800 Subject: [PATCH] Bug 549633 - Standardize record creation so all SyncEngines encrypt data [r=mconnor] Always add the id and encryption value so client and delete records can be encrypted. --- services/sync/modules/engines.js | 7 +++++-- services/sync/modules/engines/bookmarks.js | 5 +---- services/sync/modules/engines/clients.js | 5 ++--- services/sync/modules/engines/forms.js | 4 +--- services/sync/modules/engines/history.js | 4 +--- services/sync/modules/engines/passwords.js | 4 +--- services/sync/modules/engines/prefs.js | 4 +--- services/sync/modules/engines/tabs.js | 4 +--- 8 files changed, 13 insertions(+), 24 deletions(-) diff --git a/services/sync/modules/engines.js b/services/sync/modules/engines.js index 48abea913d17..e65c6ca40aec 100644 --- a/services/sync/modules/engines.js +++ b/services/sync/modules/engines.js @@ -333,9 +333,12 @@ SyncEngine.prototype = { this._toFetch = o)); }, - // Create a new record by querying the store, and add the engine metadata + // Create a new record using the store and add in crypto fields _createRecord: function SyncEngine__createRecord(id) { - return this._store.createRecord(id, this.cryptoMetaURL); + let record = this._store.createRecord(id); + record.id = id; + record.encryption = this.cryptoMetaURL; + return record; }, // Any setup that needs to happen at the beginning of each sync. diff --git a/services/sync/modules/engines/bookmarks.js b/services/sync/modules/engines/bookmarks.js index bfb138ddba74..f4edb03cb60f 100644 --- a/services/sync/modules/engines/bookmarks.js +++ b/services/sync/modules/engines/bookmarks.js @@ -704,11 +704,10 @@ BookmarksStore.prototype = { }, // Create a record starting from the weave id (places guid) - createRecord: function BStore_createRecord(guid, cryptoMetaURL) { + createRecord: function createRecord(guid) { let placeId = idForGUID(guid); if (placeId <= 0) { // deleted item record = new PlacesItem(); - record.id = guid; record.deleted = true; return record; } @@ -787,10 +786,8 @@ BookmarksStore.prototype = { this._bms.getItemType(placeId)); } - record.id = guid; record.parentid = this._getParentGUIDForId(placeId); record.predecessorid = this._getPredecessorGUIDForId(placeId); - record.encryption = cryptoMetaURL; record.sortindex = this._calculateIndex(record); return record; diff --git a/services/sync/modules/engines/clients.js b/services/sync/modules/engines/clients.js index 43f795b627fa..4cf266e7c5ec 100644 --- a/services/sync/modules/engines/clients.js +++ b/services/sync/modules/engines/clients.js @@ -211,10 +211,9 @@ ClientStore.prototype = { this.update(record); }, - createRecord: function ClientStore_createRecord(id) { + createRecord: function createRecord(guid) { let record = new ClientRecord(); - record.id = id; - record.payload = this.clients[id]; + record.payload = this.clients[guid]; return record; }, diff --git a/services/sync/modules/engines/forms.js b/services/sync/modules/engines/forms.js index ea5913acf41a..c8106db68581 100644 --- a/services/sync/modules/engines/forms.js +++ b/services/sync/modules/engines/forms.js @@ -155,13 +155,11 @@ FormStore.prototype = { return (id in this._formItems); }, - createRecord: function FormStore_createRecord(guid, cryptoMetaURL) { + createRecord: function createRecord(guid) { let record = new FormRec(); - record.id = guid; if (guid in this._formItems) { let item = this._formItems[guid]; - record.encryption = cryptoMetaURL; record.name = item.name; record.value = item.value; } else { diff --git a/services/sync/modules/engines/history.js b/services/sync/modules/engines/history.js index c1ef22a2073a..04378d91ff51 100644 --- a/services/sync/modules/engines/history.js +++ b/services/sync/modules/engines/history.js @@ -249,16 +249,14 @@ HistoryStore.prototype = { return url ? this._hsvc.isVisited(url) : false; }, - createRecord: function HistStore_createRecord(guid, cryptoMetaURL) { + createRecord: function createRecord(guid) { let foo = this._findURLByGUID(guid); let record = new HistoryRec(); - record.id = guid; if (foo) { record.histUri = foo.url; record.title = foo.title; record.sortindex = foo.frecency; record.visits = this._getVisits(record.histUri); - record.encryption = cryptoMetaURL; } else record.deleted = true; diff --git a/services/sync/modules/engines/passwords.js b/services/sync/modules/engines/passwords.js index 00c506adfca0..067575f0d31b 100644 --- a/services/sync/modules/engines/passwords.js +++ b/services/sync/modules/engines/passwords.js @@ -170,13 +170,11 @@ PasswordStore.prototype = { return false; }, - createRecord: function PasswordStore__createRecord(guid, cryptoMetaURL) { + createRecord: function createRecord(guid) { let record = new LoginRec(); let login = this._getLoginFromGUID(guid); - record.id = guid; if (login) { - record.encryption = cryptoMetaURL; record.hostname = login.hostname; record.formSubmitURL = login.formSubmitURL; record.httpRealm = login.httpRealm; diff --git a/services/sync/modules/engines/prefs.js b/services/sync/modules/engines/prefs.js index ca4b7249e2c9..1d95c143ab71 100644 --- a/services/sync/modules/engines/prefs.js +++ b/services/sync/modules/engines/prefs.js @@ -182,12 +182,10 @@ PrefStore.prototype = { return (id === WEAVE_PREFS_GUID); }, - createRecord: function FormStore_createRecord(guid, cryptoMetaURL) { + createRecord: function createRecord(guid) { let record = new PrefRec(); - record.id = guid; if (guid == WEAVE_PREFS_GUID) { - record.encryption = cryptoMetaURL; record.value = this._getAllPrefs(); } else { record.deleted = true; diff --git a/services/sync/modules/engines/tabs.js b/services/sync/modules/engines/tabs.js index 4b4422ea15b3..525a4933caff 100644 --- a/services/sync/modules/engines/tabs.js +++ b/services/sync/modules/engines/tabs.js @@ -149,7 +149,7 @@ TabStore.prototype = { return allTabs; }, - createRecord: function TabStore_createRecord(id, cryptoMetaURL) { + createRecord: function createRecord(guid) { let record = new TabSetRecord(); record.clientName = Clients.clientName; @@ -161,8 +161,6 @@ TabStore.prototype = { this._log.trace("Wrapping tab: " + JSON.stringify(tab)); }, this); - record.id = id; - record.encryption = cryptoMetaURL; return record; },