mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-06-06 01:21:39 +00:00
Properly delete dependent apps and their corresponding devices
This commit is contained in:
parent
3a86d8ec48
commit
9af4ed0397
@ -1,3 +1,5 @@
|
|||||||
|
* Properly delete dependent apps and their corresponding devices [Pablo]
|
||||||
|
|
||||||
# v2.8.0
|
# v2.8.0
|
||||||
|
|
||||||
* Add HostConfig in container create instead of start [Pablo]
|
* Add HostConfig in container create instead of start [Pablo]
|
||||||
|
@ -239,8 +239,7 @@ exports.fetchAndSetTargetsForDependentApps = (state, fetchFn, apiKey) ->
|
|||||||
return app.commit? and app.imageId? and !_.some(localApps, imageId: app.imageId)
|
return app.commit? and app.imageId? and !_.some(localApps, imageId: app.imageId)
|
||||||
toBeRemoved = _.filter localApps, (app, appId) ->
|
toBeRemoved = _.filter localApps, (app, appId) ->
|
||||||
return app.commit? and !_.some(remoteApps, imageId: app.imageId)
|
return app.commit? and !_.some(remoteApps, imageId: app.imageId)
|
||||||
toBeDeletedFromDB = _.filter localApps, (app, appId) ->
|
toBeDeletedFromDB = _(localApps).reject((app, appId) -> remoteApps[appId]?).map('appId').value()
|
||||||
return !remoteApps[appId]?
|
|
||||||
Promise.map toBeDownloaded, (app) ->
|
Promise.map toBeDownloaded, (app) ->
|
||||||
fetchFn(app, false)
|
fetchFn(app, false)
|
||||||
.then ->
|
.then ->
|
||||||
@ -258,7 +257,9 @@ exports.fetchAndSetTargetsForDependentApps = (state, fetchFn, apiKey) ->
|
|||||||
knex('dependentApp').insert(app) if n == 0
|
knex('dependentApp').insert(app) if n == 0
|
||||||
)
|
)
|
||||||
.then ->
|
.then ->
|
||||||
knex('dependentApp').del().whereIn('appId', _.keys(toBeDeletedFromDB))
|
knex('dependentDevice').del().whereIn('appId', toBeDeletedFromDB)
|
||||||
|
.then ->
|
||||||
|
knex('dependentApp').del().whereIn('appId', toBeDeletedFromDB)
|
||||||
.then ->
|
.then ->
|
||||||
knex('dependentDevice').update({ markedForDeletion: true }).whereNotIn('uuid', _.keys(state.devices))
|
knex('dependentDevice').update({ markedForDeletion: true }).whereNotIn('uuid', _.keys(state.devices))
|
||||||
.then ->
|
.then ->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user