summaryrefslogtreecommitdiffstats
path: root/services/sync/modules/addonsreconciler.js
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-10-06 06:57:51 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-10-06 06:57:51 +0200
commit0c47c83e1b3b7d95681a43fbb0de0e17b2cd5b25 (patch)
treec321601f04cbfd02fb6e12878e745dc49a612c86 /services/sync/modules/addonsreconciler.js
parent8860eddcee1417483cafd114f3a9ec127e0f1f74 (diff)
downloadUXP-0c47c83e1b3b7d95681a43fbb0de0e17b2cd5b25.tar
UXP-0c47c83e1b3b7d95681a43fbb0de0e17b2cd5b25.tar.gz
UXP-0c47c83e1b3b7d95681a43fbb0de0e17b2cd5b25.tar.lz
UXP-0c47c83e1b3b7d95681a43fbb0de0e17b2cd5b25.tar.xz
UXP-0c47c83e1b3b7d95681a43fbb0de0e17b2cd5b25.zip
Import Tycho weave client
Diffstat (limited to 'services/sync/modules/addonsreconciler.js')
-rw-r--r--services/sync/modules/addonsreconciler.js35
1 files changed, 16 insertions, 19 deletions
diff --git a/services/sync/modules/addonsreconciler.js b/services/sync/modules/addonsreconciler.js
index a60fc8d56..2e838e885 100644
--- a/services/sync/modules/addonsreconciler.js
+++ b/services/sync/modules/addonsreconciler.js
@@ -17,7 +17,7 @@
"use strict";
-var Cu = Components.utils;
+const Cu = Components.utils;
Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://services-sync/util.js");
@@ -218,12 +218,11 @@ AddonsReconciler.prototype = {
}
this._addons = json.addons;
- for (let id in this._addons) {
- let record = this._addons[id];
+ for each (let record in this._addons) {
record.modified = new Date(record.modified);
}
- for (let [time, change, id] of json.changes) {
+ for each (let [time, change, id] in json.changes) {
this._changes.push([new Date(time), change, id]);
}
@@ -247,9 +246,9 @@ AddonsReconciler.prototype = {
let file = path || DEFAULT_STATE_FILE;
let state = {version: 1, addons: {}, changes: []};
- for (let [id, record] of Object.entries(this._addons)) {
+ for (let [id, record] in Iterator(this._addons)) {
state.addons[id] = {};
- for (let [k, v] of Object.entries(record)) {
+ for (let [k, v] in Iterator(record)) {
if (k == "modified") {
state.addons[id][k] = v.getTime();
}
@@ -259,7 +258,7 @@ AddonsReconciler.prototype = {
}
}
- for (let [time, change, id] of this._changes) {
+ for each (let [time, change, id] in this._changes) {
state.changes.push([time.getTime(), change, id]);
}
@@ -351,14 +350,14 @@ AddonsReconciler.prototype = {
AddonManager.getAllAddons(function (addons) {
let ids = {};
- for (let addon of addons) {
+ for each (let addon in addons) {
ids[addon.id] = true;
this.rectifyStateFromAddon(addon);
}
// Look for locally-defined add-ons that no longer exist and update their
// record.
- for (let [id, addon] of Object.entries(this._addons)) {
+ for (let [id, addon] in Iterator(this._addons)) {
if (id in ids) {
continue;
}
@@ -374,7 +373,7 @@ AddonsReconciler.prototype = {
}
let installFound = false;
- for (let install of installs) {
+ for each (let install in installs) {
if (install.addon && install.addon.id == id &&
install.state == AddonManager.STATE_INSTALLED) {
@@ -417,7 +416,7 @@ AddonsReconciler.prototype = {
* Addon instance being updated.
*/
rectifyStateFromAddon: function rectifyStateFromAddon(addon) {
- this._log.debug(`Rectifying state for addon ${addon.name} (version=${addon.version}, id=${addon.id})`);
+ this._log.debug("Rectifying state for addon: " + addon.id);
this._ensureStateLoaded();
let id = addon.id;
@@ -434,8 +433,7 @@ AddonsReconciler.prototype = {
modified: now,
type: addon.type,
scope: addon.scope,
- foreignInstall: addon.foreignInstall,
- isSyncable: addon.isSyncable,
+ foreignInstall: addon.foreignInstall
};
this._addons[id] = record;
this._log.debug("Adding change because add-on not present locally: " +
@@ -445,7 +443,6 @@ AddonsReconciler.prototype = {
}
let record = this._addons[id];
- record.isSyncable = addon.isSyncable;
if (!record.installed) {
// It is possible the record is marked as uninstalled because an
@@ -486,11 +483,12 @@ AddonsReconciler.prototype = {
this._log.info("Change recorded for " + state.id);
this._changes.push([date, change, state.id]);
- for (let listener of this._listeners) {
+ for each (let listener in this._listeners) {
try {
listener.changeListener.call(listener, date, change, state);
} catch (ex) {
- this._log.warn("Exception calling change listener", ex);
+ this._log.warn("Exception calling change listener: " +
+ Utils.exceptionStr(ex));
}
}
},
@@ -556,8 +554,7 @@ AddonsReconciler.prototype = {
* @return Object on success on null on failure.
*/
getAddonStateFromSyncGUID: function getAddonStateFromSyncGUID(guid) {
- for (let id in this.addons) {
- let addon = this.addons[id];
+ for each (let addon in this.addons) {
if (addon.guid == guid) {
return addon;
}
@@ -636,7 +633,7 @@ AddonsReconciler.prototype = {
}
}
catch (ex) {
- this._log.warn("Exception", ex);
+ this._log.warn("Exception: " + Utils.exceptionStr(ex));
}
},