diff --git a/src/apptask.js b/src/apptask.js index 35bd1a0be..91abc989e 100644 --- a/src/apptask.js +++ b/src/apptask.js @@ -505,7 +505,7 @@ function install(app, restoreConfig, progressCallback, callback) { assert.strictEqual(typeof progressCallback, 'function'); assert.strictEqual(typeof callback, 'function'); - const isRestoring = app.installationState === appdb.ISTATE_PENDING_RESTORE; + const isInstalling = app.installationState !== appdb.ISTATE_PENDING_RESTORE; // install or clone async.series([ // this protects against the theoretical possibility of an app being marked for install/restore from @@ -521,7 +521,7 @@ function install(app, restoreConfig, progressCallback, callback) { deleteContainers.bind(null, app, { managedOnly: true }), function teardownAddons(next) { // when restoring, app does not require these addons anymore. remove carefully to preserve the db passwords - var addonsToRemove = !isRestoring ? app.manifest.addons : _.omit(restoreConfig.oldManifest.addons, Object.keys(app.manifest.addons)); + var addonsToRemove = isInstalling ? app.manifest.addons : _.omit(restoreConfig.oldManifest.addons, Object.keys(app.manifest.addons)); addons.teardownAddons(app, addonsToRemove, next); }, @@ -529,7 +529,7 @@ function install(app, restoreConfig, progressCallback, callback) { // for restore case function deleteImageIfChanged(done) { - if (!restoreConfig.oldManifest) return done(); + if (isInstalling) return done(); if (restoreConfig.oldManifest.dockerImage === app.manifest.dockerImage) return done(); @@ -542,10 +542,10 @@ function install(app, restoreConfig, progressCallback, callback) { downloadIcon.bind(null, app), progressCallback.bind(null, { percent: 30, message: 'Registering subdomain' }), - registerSubdomain.bind(null, app, isRestoring /* overwrite */), + registerSubdomain.bind(null, app, !isInstalling /* overwrite */), progressCallback.bind(null, { percent: 35, message: 'Registering alternate domains' }), - registerAlternateDomains.bind(null, app, isRestoring /* overwrite */), + registerAlternateDomains.bind(null, app, !isInstalling /* overwrite */), progressCallback.bind(null, { percent: 40, message: 'Downloading image' }), downloadImage.bind(null, app.manifest),