Make restore/configure use scheduleTask

This commit is contained in:
Girish Ramakrishnan
2019-08-28 15:36:50 -07:00
parent 05d3897ae2
commit 6a7fc17c60

View File

@@ -1419,14 +1419,14 @@ function restoreInstalledApps(callback) {
async.map(apps, function (app, iteratorDone) {
backups.getByAppIdPaged(1, 1, app.id, function (error, results) {
const restoreConfig = !error && results.length ? { backupId: results[0].id, backupFormat: results[0].format } : null;
const restoreConfig = !error && results.length ? { backupId: results[0].id, backupFormat: results[0].format, oldManifest: app.manifest } : null;
debug(`marking ${app.fqdn} for restore using restore config ${JSON.stringify(restoreConfig)}`);
appdb.setInstallationCommand(app.id, appdb.ISTATE_PENDING_RESTORE, { restoreConfig: restoreConfig }, function (error) {
if (error) debug(`Error marking ${app.fqdn} for restore: ${JSON.stringify(error)}`);
iteratorDone(); // always succeed
scheduleTask(app.id, { restoreConfig }, () => iteratorDone()); // always succeed
});
});
}, callback);
@@ -1445,7 +1445,7 @@ function configureInstalledApps(callback) {
appdb.setInstallationCommand(app.id, appdb.ISTATE_PENDING_CONFIGURE, { }, function (error) {
if (error) debug(`Error marking ${app.fqdn} for reconfigure: ${JSON.stringify(error)}`);
iteratorDone(); // always succeed
scheduleTask(app.id, { oldConfig: getAppConfig(app) }, () => iteratorDone()); // always succeed
});
}, callback);
});