repair: Use backupId only if passed in via REST API

This commit is contained in:
Girish Ramakrishnan
2019-09-30 09:13:13 -07:00
parent ce9224c690
commit fc90829ba2

View File

@@ -1407,8 +1407,10 @@ function repair(appId, data, auditSource, callback) {
tasks.get(appError.taskId || '', function (error, task) {
let args = !error ? task.args[1] : {}; // the first argument is the app id
args.restoreConfig = data.backupId ? { backupId: data.backupId, backupFormat: data.backupFormat, oldManifest: app.manifest } : null; // when null, apptask simply reinstalls
args.overwriteDns = 'overwriteDns' in data ? data.overwriteDns : false;
if ('backupId' in data) {
args.restoreConfig = data.backupId ? { backupId: data.backupId, backupFormat: data.backupFormat, oldManifest: app.manifest } : null; // when null, apptask simply reinstalls
}
if ('overwriteDns' in data) args.overwriteDns = data.overwriteDns;
// create a new task instead of updating the old one, since it helps tracking
addTask(appId, newState, { args, values, requiredState: exports.ISTATE_ERROR }, function (error, result) {