Store_applyIncoming, SyncEngine__applyIncoming: async + async/yield -> sync.

This commit is contained in:
Edward Lee 2009-06-05 00:36:11 -07:00
parent fce5aa36de
commit 3a4f2ca0ee
2 changed files with 9 additions and 14 deletions

View File

@ -353,7 +353,7 @@ SyncEngine.prototype = {
item.decrypt(ID.get('WeaveCryptoID').password);
if (this._reconcile(item)) {
count.applied++;
yield this._applyIncoming.async(this, self.cb, item);
this._applyIncoming(item);
} else {
count.reconciled++;
this._log.trace("Skipping reconciled incoming item " + item.id);
@ -442,11 +442,10 @@ SyncEngine.prototype = {
// Apply incoming records
_applyIncoming: function SyncEngine__applyIncoming(item) {
let self = yield;
this._log.trace("Incoming:\n" + item);
try {
this._tracker.ignoreAll = true;
yield this._store.applyIncoming(self.cb, item);
this._store.applyIncoming(item);
if (this._lastSyncTmp < item.modified)
this._lastSyncTmp = item.modified;
} catch (e) {

View File

@ -74,17 +74,13 @@ Store.prototype = {
this._log = Log4Moz.repository.getLogger("Store." + this._logName);
},
applyIncoming: function Store_applyIncoming(onComplete, record) {
let fn = function(rec) {
let self = yield;
if (rec.deleted)
this.remove(rec);
else if (!this.itemExists(rec.id))
this.create(rec);
else
this.update(rec);
};
fn.async(this, onComplete, record);
applyIncoming: function Store_applyIncoming(record) {
if (record.deleted)
this.remove(record);
else if (!this.itemExists(record.id))
this.create(record);
else
this.update(record);
},
// override these in derived objects