Skip moving data if source and target are same

This commit is contained in:
Girish Ramakrishnan
2019-12-06 08:09:43 -08:00
parent 905bb92bad
commit 2ffb32ae60

View File

@@ -471,6 +471,8 @@ function moveDataDir(app, targetDir, callback) {
debug(`moveDataDir: migrating data from ${resolvedSourceDir} to ${resolvedTargetDir}`);
if (resolvedSourceDir === resolvedTargetDir) return callback();
shell.sudo('moveDataDir', [ MV_VOLUME_CMD, resolvedSourceDir, resolvedTargetDir ], {}, function (error) {
if (error) return callback(new BoxError(BoxError.EXTERNAL_ERROR, `Error migrating data directory: ${error.message}`));
@@ -751,16 +753,10 @@ function migrateDataDir(app, args, progressCallback, callback) {
progressCallback.bind(null, { percent: 50, message: 'Setting up addons' }),
addons.setupAddons.bind(null, _.extend({}, app, { dataDir: newDataDir }), app.manifest.addons),
// migrate dataDir
function (next) {
const dataDirChanged = newDataDir !== app.dataDir;
progressCallback.bind(null, { percent: 60, message: 'Moving data dir' }),
moveDataDir.bind(null, app, newDataDir),
if (!dataDirChanged) return next();
moveDataDir(app, newDataDir, next);
},
progressCallback.bind(null, { percent: 60, message: 'Creating container' }),
progressCallback.bind(null, { percent: 90, message: 'Creating container' }),
createContainer.bind(null, app),
startApp.bind(null, app),