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

This commit is contained in:
Dan Mills 2009-01-14 22:01:04 -08:00
Родитель ce64889074
Коммит 1420201b13
3 изменённых файлов: 15 добавлений и 9 удалений

Просмотреть файл

@ -296,13 +296,16 @@ SyncEngine.prototype = {
yield newitems.get(self.cb); yield newitems.get(self.cb);
let item; let item;
let count = {applied: 0, reconciled: 0};
this._lastSyncTmp = 0; this._lastSyncTmp = 0;
while ((item = yield newitems.iter.next(self.cb))) { while ((item = yield newitems.iter.next(self.cb))) {
this._lowMemCheck(); this._lowMemCheck();
yield item.decrypt(self.cb, ID.get('WeaveCryptoID').password); 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); yield this._applyIncoming.async(this, self.cb, item);
else { } else {
count.reconciled++;
this._log.trace("Skipping reconciled incoming item " + item.id); this._log.trace("Skipping reconciled incoming item " + item.id);
if (this._lastSyncTmp < item.modified) if (this._lastSyncTmp < item.modified)
this._lastSyncTmp = item.modified; this._lastSyncTmp = item.modified;
@ -311,6 +314,9 @@ SyncEngine.prototype = {
if (this.lastSync < this._lastSyncTmp) if (this.lastSync < this._lastSyncTmp)
this.lastSync = this._lastSyncTmp; this.lastSync = this._lastSyncTmp;
this._log.info("Applied " + count.applied + " records, reconciled " +
count.reconciled + " records");
// try to free some memory // try to free some memory
this._store.cache.clear(); this._store.cache.clear();
Cu.forceGC(); Cu.forceGC();
@ -387,7 +393,7 @@ SyncEngine.prototype = {
let self = yield; let self = yield;
this._log.trace("Incoming:\n" + item); this._log.trace("Incoming:\n" + item);
try { try {
this._tracker.ignoreID(item.id); this._tracker.ignoreAll = true;
yield this._store.applyIncoming(self.cb, item); yield this._store.applyIncoming(self.cb, item);
if (this._lastSyncTmp < item.modified) if (this._lastSyncTmp < item.modified)
this._lastSyncTmp = item.modified; this._lastSyncTmp = item.modified;
@ -395,7 +401,7 @@ SyncEngine.prototype = {
this._log.warn("Error while applying incoming record: " + this._log.warn("Error while applying incoming record: " +
(e.message? e.message : e)); (e.message? e.message : e));
} finally { } 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 // do the upload
yield up.post(self.cb); yield up.post(self.cb);

Просмотреть файл

@ -414,8 +414,7 @@ HistoryTracker.prototype = {
// FIXME: very roundabout way of getting url -> guid mapping! // FIXME: very roundabout way of getting url -> guid mapping!
// FIXME2: not updated after startup // FIXME2: not updated after startup
let store = new HistoryStore(); let all = this._store.getAllIDs();
let all = store.getAllIDs();
this._all = {}; this._all = {};
for (let guid in all) { for (let guid in all) {
this._all[all[guid]] = guid; this._all[all[guid]] = guid;

Просмотреть файл

@ -77,6 +77,7 @@ Tracker.prototype = {
this._log = Log4Moz.repository.getLogger(this._logName); this._log = Log4Moz.repository.getLogger(this._logName);
this._score = 0; this._score = 0;
this._ignored = []; this._ignored = [];
this.ignoreAll = false;
this.loadChangedIDs(); this.loadChangedIDs();
}, },
@ -171,7 +172,7 @@ Tracker.prototype = {
this._log.warn("Attempted to add undefined ID to tracker"); this._log.warn("Attempted to add undefined ID to tracker");
return false; return false;
} }
if (id in this._ignored) if (this.ignoreAll || (id in this._ignored))
return false; return false;
if (!this.changedIDs[id]) { if (!this.changedIDs[id]) {
this._log.debug("Adding changed ID " + id); this._log.debug("Adding changed ID " + id);
@ -186,7 +187,7 @@ Tracker.prototype = {
this._log.warn("Attempted to remove undefined ID to tracker"); this._log.warn("Attempted to remove undefined ID to tracker");
return false; return false;
} }
if (id in this._ignored) if (this.ignoreAll || (id in this._ignored))
return false; return false;
if (this.changedIDs[id]) { if (this.changedIDs[id]) {
this._log.debug("Removing changed ID " + id); this._log.debug("Removing changed ID " + id);