restore: only take non-empty backupId

This commit is contained in:
Girish Ramakrishnan
2019-12-05 21:15:09 -08:00
parent c5e5bb90e3
commit 3926efd153
2 changed files with 6 additions and 7 deletions
+4 -4
View File
@@ -1391,9 +1391,9 @@ function repair(appId, data, auditSource, callback) {
});
}
function restore(appId, data, auditSource, callback) {
function restore(appId, backupId, auditSource, callback) {
assert.strictEqual(typeof appId, 'string');
assert.strictEqual(typeof data, 'object');
assert.strictEqual(typeof backupId, 'string');
assert.strictEqual(typeof auditSource, 'object');
assert.strictEqual(typeof callback, 'function');
@@ -1406,7 +1406,7 @@ function restore(appId, data, auditSource, callback) {
if (error) return callback(error);
// for empty or null backupId, use existing manifest to mimic a reinstall
var func = data.backupId ? backups.get.bind(null, data.backupId) : function (next) { return next(null, { manifest: app.manifest }); };
var func = backupId ? backups.get.bind(null, backupId) : function (next) { return next(null, { manifest: app.manifest }); };
func(function (error, backupInfo) {
if (error) return callback(error);
@@ -1417,7 +1417,7 @@ function restore(appId, data, auditSource, callback) {
error = checkManifestConstraints(backupInfo.manifest);
if (error) return callback(error);
const restoreConfig = { backupId: data.backupId, backupFormat: backupInfo.format, oldManifest: app.manifest };
const restoreConfig = { backupId, backupFormat: backupInfo.format, oldManifest: app.manifest };
const task = {
args: {