Move oldManifest out of restoreConfig

This commit is contained in:
Girish Ramakrishnan
2019-12-06 09:42:05 -08:00
parent 9c809aa6e1
commit 37d7be93b5
2 changed files with 16 additions and 13 deletions
+5 -6
View File
@@ -515,6 +515,7 @@ function install(app, args, progressCallback, callback) {
const restoreConfig = args.restoreConfig; // has to be set when restoring
const overwriteDns = args.overwriteDns;
const oldManifest = args.oldManifest;
async.series([
// this protects against the theoretical possibility of an app being marked for install/restore from
@@ -528,8 +529,8 @@ function install(app, args, progressCallback, callback) {
function teardownAddons(next) {
// when restoring, app does not require these addons anymore. remove carefully to preserve the db passwords
let addonsToRemove;
if (restoreConfig && restoreConfig.oldManifest) { // oldManifest is null for clone
addonsToRemove = _.omit(restoreConfig.oldManifest.addons, Object.keys(app.manifest.addons));
if (oldManifest) {
addonsToRemove = _.omit(oldManifest.addons, Object.keys(app.manifest.addons));
} else {
addonsToRemove = app.manifest.addons;
}
@@ -544,11 +545,9 @@ function install(app, args, progressCallback, callback) {
},
function deleteImageIfChanged(done) {
if (!restoreConfig || !restoreConfig.oldManifest) return done();
if (!oldManifest || oldManifest.dockerImage === app.manifest.dockerImage) return done();
if (restoreConfig.oldManifest.dockerImage === app.manifest.dockerImage) return done();
docker.deleteImage(restoreConfig.oldManifest, done);
docker.deleteImage(oldManifest, done);
},
reserveHttpPort.bind(null, app),