mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-20 17:52:51 +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
|
||||
|
||||
* 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)
|
||||
toBeRemoved = _.filter localApps, (app, appId) ->
|
||||
return app.commit? and !_.some(remoteApps, imageId: app.imageId)
|
||||
toBeDeletedFromDB = _.filter localApps, (app, appId) ->
|
||||
return !remoteApps[appId]?
|
||||
toBeDeletedFromDB = _(localApps).reject((app, appId) -> remoteApps[appId]?).map('appId').value()
|
||||
Promise.map toBeDownloaded, (app) ->
|
||||
fetchFn(app, false)
|
||||
.then ->
|
||||
@ -258,7 +257,9 @@ exports.fetchAndSetTargetsForDependentApps = (state, fetchFn, apiKey) ->
|
||||
knex('dependentApp').insert(app) if n == 0
|
||||
)
|
||||
.then ->
|
||||
knex('dependentApp').del().whereIn('appId', _.keys(toBeDeletedFromDB))
|
||||
knex('dependentDevice').del().whereIn('appId', toBeDeletedFromDB)
|
||||
.then ->
|
||||
knex('dependentApp').del().whereIn('appId', toBeDeletedFromDB)
|
||||
.then ->
|
||||
knex('dependentDevice').update({ markedForDeletion: true }).whereNotIn('uuid', _.keys(state.devices))
|
||||
.then ->
|
||||
|
Loading…
x
Reference in New Issue
Block a user