do not delete data dir for in-place import

This commit is contained in:
Girish Ramakrishnan
2019-12-05 10:40:32 -08:00
parent c07e215148
commit e8c5f8164c
2 changed files with 19 additions and 18 deletions

View File

@@ -14,7 +14,7 @@ exports = module.exports = {
restore: restore,
backupApp: backupApp,
restoreApp: restoreApp,
downloadApp: downloadApp,
backupBoxAndApps: backupBoxAndApps,
@@ -651,19 +651,12 @@ function restore(backupConfig, backupId, progressCallback, callback) {
});
}
function restoreApp(app, addonsToRestore, restoreConfig, progressCallback, callback) {
function downloadApp(app, restoreConfig, progressCallback, callback) {
assert.strictEqual(typeof app, 'object');
assert.strictEqual(typeof addonsToRestore, 'object');
assert.strictEqual(typeof restoreConfig, 'object');
assert.strictEqual(typeof progressCallback, 'function');
assert.strictEqual(typeof callback, 'function');
if (!restoreConfig.backupId) { // in-place import
debug('restoreApp: in-place import');
return addons.restoreAddons(app, addonsToRestore, callback);
}
const appDataDir = safe.fs.realpathSync(path.join(paths.APPS_DATA_DIR, app.id));
if (!appDataDir) return callback(safe.error);
const dataLayout = new DataLayout(appDataDir, app.dataDir ? [{ localDir: app.dataDir, remoteDir: 'data' }] : []);
@@ -674,11 +667,8 @@ function restoreApp(app, addonsToRestore, restoreConfig, progressCallback, callb
getBackupConfigFunc(function (error, backupConfig) {
if (error) return callback(error);
async.series([
download.bind(null, backupConfig, restoreConfig.backupId, restoreConfig.backupFormat, dataLayout, progressCallback),
addons.restoreAddons.bind(null, app, addonsToRestore)
], function (error) {
debug('restoreApp: time: %s', (new Date() - startTime)/1000);
download(backupConfig, restoreConfig.backupId, restoreConfig.backupFormat, dataLayout, progressCallback, function (error) {
debug('downloadApp: time: %s', (new Date() - startTime)/1000);
callback(error);
});