make changeItemID exclusively a store method
authorDan Mills <thunder@mozilla.com>
Mon, 08 Dec 2008 13:21:25 -0800
changeset 45091 879687443d562fa306ee177cbb802aeb56612ff5
parent 45090 e59cb69d2395840fe1155028d22d9c99b40d45bc
child 45092 39d5ec218f66f73f9747385bcfb4dd00965b6932
push idunknown
push userunknown
push dateunknown
make changeItemID exclusively a store method
services/sync/modules/engines.js
services/sync/modules/engines/bookmarks.js
--- a/services/sync/modules/engines.js
+++ b/services/sync/modules/engines.js
@@ -319,21 +319,16 @@ SyncEngine.prototype = {
   _changeRecordRefs: function SyncEngine__changeRecordRefs(oldID, newID) {
     let self = yield;
     for each (let rec in this.outgoing) {
       if (rec.parentid == oldID)
         rec.parentid = newID;
     }
   },
 
-  _changeItemID: function SyncEngine__changeItemID(oldID, newID) {
-    let self = yield;
-    throw "_changeRecordID must be overridden in a subclass";
-  },
-
   _recDepth: function SyncEngine__recDepth(rec) {
     // we've calculated depth for this record already
     if (rec.depth)
       return rec.depth;
 
     // record has no parent
     if (!rec.parentid)
       return 0;
@@ -503,19 +498,18 @@ SyncEngine.prototype = {
     for (let i = 0; i < this.incoming.length; i++) {
       for (let o = 0; o < this.outgoing.length; o++) {
         if (this._recordLike(this.incoming[i], this.outgoing[o])) {
           // change refs in outgoing queue
           yield this._changeRecordRefs.async(this, self.cb,
                                              this.outgoing[o].id,
                                              this.incoming[i].id);
           // change actual id of item
-          yield this._changeItemID.async(this, self.cb,
-                                         this.outgoing[o].id,
-                                         this.incoming[i].id);
+          this._store.changeItemID(this.outgoing[o].id,
+                                   this.incoming[i].id);
           delete this.incoming[i];
           delete this.outgoing[o];
           break;
         }
       }
       this._outgoing = this.outgoing.filter(function(n) n); // removes any holes
     }
     this._incoming = this.incoming.filter(function(n) n); // removes any holes
--- a/services/sync/modules/engines/bookmarks.js
+++ b/services/sync/modules/engines/bookmarks.js
@@ -113,21 +113,16 @@ BookmarksEngine.prototype = {
     let self = yield;
     for each (let rec in this.outgoing) {
       if (rec.parentid == oldID) {
         rec.parentid = newID;
         rec.cleartext.parentid = newID;
         yield rec.encrypt(self.cb, ID.get('WeaveCryptoID').password);
       }
     }
-  },
-
-  _changeItemID: function BmkEngine__changeRecordID(oldID, newID) {
-    let self = yield;
-    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,
   //     and updating incoming/outgoing shared folders after syncing
 };
 
 function BookmarksStore() {
   this._init();
@@ -453,19 +448,17 @@ BookmarksStore.prototype = {
 	break;
       default:
         this._log.warn("Can't change item property: " + key);
         break;
       }
     }
   },
 
-  _changeItemID: function BSS__changeItemID(oldID, newID) {
-    let self = yield;
-
+  changeItemID: function BStore_changeItemID(oldID, newID) {
     var itemId = this._getItemIdForGUID(oldID);
     if (itemId == null) // toplevel folder
       return;
     if (itemId < 0) {
       this._log.warn("Can't change GUID " + oldID + " to " +
                       newID + ": Item does not exist");
       return;
     }