From 1420201b133b26c8325136a0e7488fca6c19395e Mon Sep 17 00:00:00 2001 From: Dan Mills Date: Wed, 14 Jan 2009 22:01:04 -0800 Subject: [PATCH] add some extra log info to engine; have tracker ignore all changes when applying a change to prevent the tracker from generating new guids for new items before the store has a chance to set the right one --- services/sync/modules/engines.js | 16 +++++++++++----- services/sync/modules/engines/history.js | 3 +-- services/sync/modules/trackers.js | 5 +++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/services/sync/modules/engines.js b/services/sync/modules/engines.js index 069e0405a043..89767eec33c9 100644 --- a/services/sync/modules/engines.js +++ b/services/sync/modules/engines.js @@ -296,13 +296,16 @@ SyncEngine.prototype = { yield newitems.get(self.cb); let item; + let count = {applied: 0, reconciled: 0}; this._lastSyncTmp = 0; while ((item = yield newitems.iter.next(self.cb))) { this._lowMemCheck(); yield item.decrypt(self.cb, ID.get('WeaveCryptoID').password); - if (yield this._reconcile.async(this, self.cb, item)) + if (yield this._reconcile.async(this, self.cb, item)) { + count.applied++; yield this._applyIncoming.async(this, self.cb, item); - else { + } else { + count.reconciled++; this._log.trace("Skipping reconciled incoming item " + item.id); if (this._lastSyncTmp < item.modified) this._lastSyncTmp = item.modified; @@ -311,6 +314,9 @@ SyncEngine.prototype = { if (this.lastSync < this._lastSyncTmp) this.lastSync = this._lastSyncTmp; + this._log.info("Applied " + count.applied + " records, reconciled " + + count.reconciled + " records"); + // try to free some memory this._store.cache.clear(); Cu.forceGC(); @@ -387,7 +393,7 @@ SyncEngine.prototype = { let self = yield; this._log.trace("Incoming:\n" + item); try { - this._tracker.ignoreID(item.id); + this._tracker.ignoreAll = true; yield this._store.applyIncoming(self.cb, item); if (this._lastSyncTmp < item.modified) this._lastSyncTmp = item.modified; @@ -395,7 +401,7 @@ SyncEngine.prototype = { this._log.warn("Error while applying incoming record: " + (e.message? e.message : e)); } finally { - this._tracker.unignoreID(item.id); + this._tracker.ignoreAll = false; } }, @@ -434,7 +440,7 @@ SyncEngine.prototype = { } } - this._log.debug("Uploading " + outnum + " records + " + count + " index/depth records)"); + this._log.info("Uploading " + outnum + " records + " + count + " index/depth records)"); // do the upload yield up.post(self.cb); diff --git a/services/sync/modules/engines/history.js b/services/sync/modules/engines/history.js index fff12323de78..1df9938996e0 100644 --- a/services/sync/modules/engines/history.js +++ b/services/sync/modules/engines/history.js @@ -414,8 +414,7 @@ HistoryTracker.prototype = { // FIXME: very roundabout way of getting url -> guid mapping! // FIXME2: not updated after startup - let store = new HistoryStore(); - let all = store.getAllIDs(); + let all = this._store.getAllIDs(); this._all = {}; for (let guid in all) { this._all[all[guid]] = guid; diff --git a/services/sync/modules/trackers.js b/services/sync/modules/trackers.js index a6a7de8fb7e3..0bd738d4fbe2 100644 --- a/services/sync/modules/trackers.js +++ b/services/sync/modules/trackers.js @@ -77,6 +77,7 @@ Tracker.prototype = { this._log = Log4Moz.repository.getLogger(this._logName); this._score = 0; this._ignored = []; + this.ignoreAll = false; this.loadChangedIDs(); }, @@ -171,7 +172,7 @@ Tracker.prototype = { this._log.warn("Attempted to add undefined ID to tracker"); return false; } - if (id in this._ignored) + if (this.ignoreAll || (id in this._ignored)) return false; if (!this.changedIDs[id]) { this._log.debug("Adding changed ID " + id); @@ -186,7 +187,7 @@ Tracker.prototype = { this._log.warn("Attempted to remove undefined ID to tracker"); return false; } - if (id in this._ignored) + if (this.ignoreAll || (id in this._ignored)) return false; if (this.changedIDs[id]) { this._log.debug("Removing changed ID " + id);