mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
ignore/unignore specific weave IDs instead of a blanket enable/disable of the tracker during sync.
This commit is contained in:
parent
51d51a26ed
commit
445916b2e6
@ -274,8 +274,6 @@ SyncEngine.prototype = {
|
||||
|
||||
let outnum = [i for (i in this._tracker.changedIDs)].length;
|
||||
this._log.info(outnum + " outgoing items pre-reconciliation");
|
||||
|
||||
this._tracker.disable(); // FIXME: need finer-grained ignoring
|
||||
},
|
||||
|
||||
// Generate outgoing records
|
||||
@ -389,12 +387,15 @@ SyncEngine.prototype = {
|
||||
let self = yield;
|
||||
this._log.trace("Incoming:\n" + item);
|
||||
try {
|
||||
this._tracker.ignoreID(item.id);
|
||||
yield this._store.applyIncoming(self.cb, item);
|
||||
if (this._lastSyncTmp < item.modified)
|
||||
this._lastSyncTmp = item.modified;
|
||||
} catch (e) {
|
||||
this._log.warn("Error while applying incoming record: " +
|
||||
(e.message? e.message : e));
|
||||
} finally {
|
||||
this._tracker.unignoreID(item.id);
|
||||
}
|
||||
},
|
||||
|
||||
@ -451,7 +452,6 @@ SyncEngine.prototype = {
|
||||
let self = yield;
|
||||
this._log.debug("Finishing up sync");
|
||||
this._tracker.resetScore();
|
||||
this._tracker.enable();
|
||||
},
|
||||
|
||||
_sync: function SyncEngine__sync() {
|
||||
@ -467,9 +467,6 @@ SyncEngine.prototype = {
|
||||
this._log.warn("Sync failed");
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
this._tracker.enable();
|
||||
}
|
||||
},
|
||||
|
||||
_wipeServer: function SyncEngine__wipeServer() {
|
||||
|
@ -653,38 +653,39 @@ BookmarksTracker.prototype = {
|
||||
this._all[this._bms.getItemIdForGUID(guid)] = guid;
|
||||
}
|
||||
|
||||
// ignore changes to the three roots
|
||||
// we use special names for them, so ignore their "real" places guid
|
||||
// as well as ours, just in case
|
||||
this.ignoreID("menu");
|
||||
this.ignoreID("toolbar");
|
||||
this.ignoreID("unfiled");
|
||||
this.ignoreID(this._all[this._bms.bookmarksMenuFolder]);
|
||||
this.ignoreID(this._all[this._bms.toolbarFolder]);
|
||||
this.ignoreID(this._all[this._bms.unfiledBookmarksFolder]);
|
||||
|
||||
this._bms.addObserver(this, false);
|
||||
},
|
||||
|
||||
/* Every add/remove/change is worth 10 points */
|
||||
_upScore: function BMT__upScore() {
|
||||
if (!this.enabled)
|
||||
return;
|
||||
this._score += 10;
|
||||
},
|
||||
|
||||
onItemAdded: function BMT_onEndUpdateBatch(itemId, folder, index) {
|
||||
this._all[itemId] = this._bms.getItemGUID(itemId);
|
||||
//if (!this.enabled)
|
||||
//return;
|
||||
this._log.trace("onItemAdded: " + itemId);
|
||||
this.addChangedID(this._all[itemId]);
|
||||
this._upScore();
|
||||
},
|
||||
|
||||
onItemRemoved: function BMT_onItemRemoved(itemId, folder, index) {
|
||||
let guid = this._all[itemId];
|
||||
delete this._all[itemId];
|
||||
if (!this.enabled)
|
||||
return;
|
||||
this._log.trace("onItemRemoved: " + itemId);
|
||||
this.addChangedID(guid);
|
||||
this.addChangedID(this._all[itemId]);
|
||||
delete this._all[itemId];
|
||||
this._upScore();
|
||||
},
|
||||
|
||||
onItemChanged: function BMT_onItemChanged(itemId, property, isAnnotationProperty, value) {
|
||||
if (!this.enabled)
|
||||
return;
|
||||
this._log.trace("onItemChanged: " + itemId + ", property: " + property +
|
||||
", isAnno: " + isAnnotationProperty + ", value: " + value);
|
||||
|
||||
@ -705,8 +706,6 @@ BookmarksTracker.prototype = {
|
||||
},
|
||||
|
||||
onItemMoved: function BMT_onItemMoved(itemId, oldParent, oldIndex, newParent, newIndex) {
|
||||
if (!this.enabled)
|
||||
return;
|
||||
this._log.trace("onItemMoved: " + itemId);
|
||||
this.addChangedID(this._all[itemId]);
|
||||
this._upScore();
|
||||
|
@ -76,22 +76,11 @@ Tracker.prototype = {
|
||||
_init: function T__init() {
|
||||
this._log = Log4Moz.repository.getLogger(this._logName);
|
||||
this._score = 0;
|
||||
this._ignored = [];
|
||||
this.loadChangedIDs();
|
||||
this.enable();
|
||||
},
|
||||
|
||||
get enabled() {
|
||||
return this._enabled;
|
||||
},
|
||||
|
||||
enable: function T_enable() {
|
||||
this._enabled = true;
|
||||
},
|
||||
|
||||
disable: function T_disable() {
|
||||
this._enabled = false;
|
||||
},
|
||||
|
||||
/*
|
||||
* Score can be called as often as desired to decide which engines to sync
|
||||
*
|
||||
@ -163,13 +152,28 @@ Tracker.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
// ignore/unignore specific IDs. Useful for ignoring items that are
|
||||
// being processed, or that shouldn't be synced.
|
||||
// But note: not persisted to disk
|
||||
|
||||
ignoreID: function T_ignoreID(id) {
|
||||
this.unignoreID(id);
|
||||
this._ignored.push(id);
|
||||
},
|
||||
|
||||
unignoreID: function T_unignoreID(id) {
|
||||
let index = this._ignored.indexOf(id);
|
||||
if (index != -1)
|
||||
this._ignored.splice(index, 1);
|
||||
},
|
||||
|
||||
addChangedID: function T_addChangedID(id) {
|
||||
if (!this.enabled)
|
||||
return;
|
||||
if (!id) {
|
||||
this._log.warn("Attempted to add undefined ID to tracker");
|
||||
return;
|
||||
}
|
||||
if (id in this._ignored)
|
||||
return;
|
||||
this._log.debug("Adding changed ID " + id);
|
||||
if (!this.changedIDs[id]) {
|
||||
this.changedIDs[id] = true;
|
||||
@ -178,12 +182,12 @@ Tracker.prototype = {
|
||||
},
|
||||
|
||||
removeChangedID: function T_removeChangedID(id) {
|
||||
if (!this.enabled)
|
||||
return;
|
||||
if (!id) {
|
||||
this._log.warn("Attempted to remove undefined ID from tracker");
|
||||
this._log.warn("Attempted to remove undefined ID to tracker");
|
||||
return;
|
||||
}
|
||||
if (id in this._ignored)
|
||||
return;
|
||||
this._log.debug("Removing changed ID " + id);
|
||||
if (this.changedIDs[id]) {
|
||||
delete this.changedIDs[id];
|
||||
|
Loading…
Reference in New Issue
Block a user