diff --git a/src/apps.js b/src/apps.js index b886ac8f5..8a15c35c9 100644 --- a/src/apps.js +++ b/src/apps.js @@ -1199,13 +1199,13 @@ function setDataDir(appId, dataDir, auditSource, callback) { if (error) return callback(error); const task = { - args: { oldDataDir: app.dataDir }, - values: { dataDir: dataDir } + args: { newDataDir: dataDir }, + values: { } }; addTask(appId, exports.ISTATE_PENDING_DATA_DIR_MIGRATION, task, function (error, result) { if (error) return callback(error); - eventlog.add(eventlog.ACTION_APP_CONFIGURE, auditSource, { appId: appId, app: app, dataDir: dataDir, taskId: result.taskId }); + eventlog.add(eventlog.ACTION_APP_CONFIGURE, auditSource, { appId: appId, app: app, newDataDir: dataDir, taskId: result.taskId }); callback(null, { taskId: result.taskId }); }); diff --git a/src/apptask.js b/src/apptask.js index 298f24101..9e10f00bd 100644 --- a/src/apptask.js +++ b/src/apptask.js @@ -458,13 +458,13 @@ function waitForDnsPropagation(app, callback) { }); } -function moveDataDir(app, sourceDir, callback) { +function moveDataDir(app, targetDir, callback) { assert.strictEqual(typeof app, 'object'); - assert(sourceDir === null || typeof sourceDir === 'string'); + assert(targetDir === null || typeof targetDir === 'string'); assert.strictEqual(typeof callback, 'function'); - let resolvedSourceDir = apps.getDataDir(app, sourceDir); - let resolvedTargetDir = apps.getDataDir(app, app.dataDir); + let resolvedSourceDir = apps.getDataDir(app, app.dataDir); + let resolvedTargetDir = apps.getDataDir(app, targetDir); debug(`moveDataDir: migrating data from ${resolvedSourceDir} to ${resolvedTargetDir}`); @@ -721,8 +721,8 @@ function migrateDataDir(app, args, progressCallback, callback) { assert.strictEqual(typeof progressCallback, 'function'); assert.strictEqual(typeof callback, 'function'); - let oldDataDir = args.oldDataDir; - assert(oldDataDir === null || typeof oldDataDir === 'string'); + let newDataDir = args.newDataDir; + assert(newDataDir === null || typeof newDataDir === 'string'); async.series([ progressCallback.bind(null, { percent: 10, message: 'Cleaning up old install' }), @@ -733,15 +733,15 @@ function migrateDataDir(app, args, progressCallback, callback) { // re-setup addons since this creates the localStorage volume progressCallback.bind(null, { percent: 50, message: 'Setting up addons' }), - addons.setupAddons.bind(null, app, app.manifest.addons), + addons.setupAddons.bind(null, _.extend({}, app, { dataDir: newDataDir }), app.manifest.addons), // migrate dataDir function (next) { - const dataDirChanged = oldDataDir !== app.dataDir; + const dataDirChanged = newDataDir !== app.dataDir; if (!dataDirChanged) return next(); - moveDataDir(app, oldDataDir, next); + moveDataDir(app, newDataDir, next); }, progressCallback.bind(null, { percent: 60, message: 'Creating container' }), @@ -750,7 +750,7 @@ function migrateDataDir(app, args, progressCallback, callback) { startApp.bind(null, app), progressCallback.bind(null, { percent: 100, message: 'Done' }), - updateApp.bind(null, app, { installationState: apps.ISTATE_INSTALLED, error: null, health: null }) + updateApp.bind(null, app, { installationState: apps.ISTATE_INSTALLED, error: null, health: null, dataDir: newDataDir }) ], function seriesDone(error) { if (error) { debugApp(app, 'error reconfiguring : %s', error);