stopped apps should not be updated or auto-updated

This commit is contained in:
Girish Ramakrishnan
2019-12-16 13:20:56 -08:00
parent c38f7d7f93
commit 4c6566f42f
2 changed files with 5 additions and 0 deletions

View File

@@ -1229,6 +1229,8 @@ function update(appId, data, auditSource, callback) {
error = checkAppState(app, exports.ISTATE_PENDING_UPDATE);
if (error) return callback(error);
if (app.runState === exports.RSTATE_STOPPED) return callback(new BoxError(BoxError.BAD_STATE, 'Stopped apps cannot be updated'));
downloadManifest(data.appStoreId, data.manifest, function (error, appStoreId, manifest) {
if (error) return callback(error);
@@ -1749,6 +1751,8 @@ function canAutoupdateApp(app, newManifest) {
if (!app.enableAutomaticUpdate) return false;
if ((semver.major(app.manifest.version) !== 0) && (semver.major(app.manifest.version) !== semver.major(newManifest.version))) return false; // major changes are blocking
if (app.runState === exports.RSTATE_STOPPED) return false; // stopped apps won't run migration scripts and shouldn't be updated
const newTcpPorts = newManifest.tcpPorts || { };
const newUdpPorts = newManifest.udpPorts || { };
const portBindings = app.portBindings; // this is never null