From 0e2710152bd88548d222299b9b7cc19d017b7008 Mon Sep 17 00:00:00 2001 From: Pablo Carranza Velez Date: Mon, 31 Oct 2016 18:09:34 +0000 Subject: [PATCH] Only iterate through remote apps to set device config --- CHANGELOG.md | 2 ++ src/application.coffee | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27ccd0b1..77594b6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +* Only iterate through remote apps to set device config [Pablo] + # v2.8.1 * Properly delete dependent apps and their corresponding devices [Pablo] diff --git a/src/application.coffee b/src/application.coffee index 0fce1042..0026cd03 100644 --- a/src/application.coffee +++ b/src/application.coffee @@ -593,7 +593,7 @@ compareForUpdate = (localApps, remoteApps) -> return !_.isEqual(remoteApps[appId].imageId, localApps[appId].imageId) toBeDownloaded = _.union(toBeDownloaded, toBeInstalled) allAppIds = _.union(localAppIds, remoteAppIds) - return { toBeRemoved, toBeDownloaded, toBeInstalled, toBeUpdated, appsWithUpdatedConfigs, allAppIds } + return { toBeRemoved, toBeDownloaded, toBeInstalled, toBeUpdated, appsWithUpdatedConfigs, remoteAppIds, allAppIds } application.update = update = (force, scheduled = false) -> switch updateStatus.state @@ -621,15 +621,15 @@ application.update = update = (force, scheduled = false) -> .then (remoteApps) -> localApps = formatLocalApps(apps) resourcesForUpdate = compareForUpdate(localApps, remoteApps) - { toBeRemoved, toBeDownloaded, toBeInstalled, toBeUpdated, appsWithUpdatedConfigs, allAppIds } = resourcesForUpdate + { toBeRemoved, toBeDownloaded, toBeInstalled, toBeUpdated, appsWithUpdatedConfigs, remoteAppIds, allAppIds } = resourcesForUpdate if !_.isEmpty(toBeRemoved) or !_.isEmpty(toBeInstalled) or !_.isEmpty(toBeUpdated) device.setUpdateState(update_pending: true) # Run special functions against variables - remoteDeviceConfig = {} - Promise.map allAppIds, (appId) -> - _.merge(remoteDeviceConfig, JSON.parse(remoteApps[appId].config)) - .then -> + Promise.try -> + remoteDeviceConfig = {} + _.map remoteAppIds, (appId) -> + _.merge(remoteDeviceConfig, JSON.parse(remoteApps[appId].config)) device.setConfig({ targetValues: remoteDeviceConfig }) .then -> getAndApplyDeviceConfig()