From 1420201b133b26c8325136a0e7488fca6c19395e Mon Sep 17 00:00:00 2001 From: Dan Mills Date: Wed, 14 Jan 2009 22:01:04 -0800 Subject: [PATCH 1/2] 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 069e0405a04..89767eec33c 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 fff12323de7..1df9938996e 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 a6a7de8fb7e..0bd738d4fbe 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); From 476672bf5538112ccfc313013a005f1400d823ba Mon Sep 17 00:00:00 2001 From: Dan Mills Date: Thu, 15 Jan 2009 13:58:59 -0800 Subject: [PATCH 2/2] Bug 468671: Don't synchronize livemarks. Based on patch by Jorge Alves --- services/sync/modules/engines/bookmarks.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/services/sync/modules/engines/bookmarks.js b/services/sync/modules/engines/bookmarks.js index 93516285e65..e0bbc8a456c 100644 --- a/services/sync/modules/engines/bookmarks.js +++ b/services/sync/modules/engines/bookmarks.js @@ -634,6 +634,13 @@ BookmarksTracker.prototype = { return bms; }, + get _ls() { + let ls = Cc["@mozilla.org/browser/livemark-service;2"]. + getService(Ci.nsILivemarkService); + this.__defineGetter__("_ls", function() ls); + return ls; + }, + QueryInterface: XPCOMUtils.generateQI([Ci.nsINavBookmarkObserver]), _init: function BMT__init() { @@ -672,6 +679,8 @@ BookmarksTracker.prototype = { }, onItemAdded: function BMT_onEndUpdateBatch(itemId, folder, index) { + if (this._ls.isLivemark(folder)) + return; this._log.trace("onItemAdded: " + itemId); this._all[itemId] = this._bms.getItemGUID(itemId); if (this.addChangedID(this._all[itemId])) @@ -679,6 +688,8 @@ BookmarksTracker.prototype = { }, onItemRemoved: function BMT_onItemRemoved(itemId, folder, index) { + if (this._ls.isLivemark(folder)) + return; this._log.trace("onItemRemoved: " + itemId); if (this.addChangedID(this._all[itemId])) this._upScore(); @@ -686,6 +697,8 @@ BookmarksTracker.prototype = { }, onItemChanged: function BMT_onItemChanged(itemId, property, isAnno, value) { + if (this._ls.isLivemark(this._bms.getFolderIdForItem(itemId)) + return; this._log.trace("onItemChanged: " + itemId + (", " + property + (isAnno? " (anno)" : "")) + (value? (" = \"" + value + "\"") : ""));