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);
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);

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

@ -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;

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

@ -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);