Merge pull request #342 from resin-io/341-fix-device-config

Only iterate through remote apps to set device config
This commit is contained in:
Pablo Carranza Vélez 2016-11-01 09:08:08 -03:00 committed by GitHub
commit f38715177f
2 changed files with 8 additions and 6 deletions

View File

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

View File

@ -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
Promise.try ->
remoteDeviceConfig = {}
Promise.map allAppIds, (appId) ->
_.map remoteAppIds, (appId) ->
_.merge(remoteDeviceConfig, JSON.parse(remoteApps[appId].config))
.then ->
device.setConfig({ targetValues: remoteDeviceConfig })
.then ->
getAndApplyDeviceConfig()