mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-06-11 20:11:42 +00:00
fix: When setting target state, delete old apps from the same source
In commit 19cd310da3
this line was deleted,
probably to avoid deleting local mode apps when setting the API target and
viceversa but we need to delete old apps to avoid problems when moving
the device between apps.
We now filter by source to avoid the problem with local mode too.
Change-type: patch
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
This commit is contained in:
@ -742,6 +742,8 @@ module.exports = class ApplicationManager extends EventEmitter
|
|||||||
.tap (appsForDB) =>
|
.tap (appsForDB) =>
|
||||||
Promise.map appsForDB, (app) =>
|
Promise.map appsForDB, (app) =>
|
||||||
@db.upsertModel('app', app, { appId: app.appId }, trx)
|
@db.upsertModel('app', app, { appId: app.appId }, trx)
|
||||||
|
.then (appsForDB) ->
|
||||||
|
trx('app').where({ source }).whereNotIn('appId', _.map(appsForDB, 'appId')).del()
|
||||||
.then =>
|
.then =>
|
||||||
@proxyvisor.setTargetInTransaction(dependent, trx)
|
@proxyvisor.setTargetInTransaction(dependent, trx)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user