diff --git a/src/apps.js b/src/apps.js index 252c7f02b..b9a34755a 100644 --- a/src/apps.js +++ b/src/apps.js @@ -596,9 +596,12 @@ function scheduleTask(appId, args, values, callback) { if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error)); appTaskManager.scheduleTask(appId, taskId, function (error) { + debug(`scheduleTask: task ${taskId} of $${appId} completed`); if (error && (error.crashed || error.stopped)) { debug(`Apptask crashed/stopped: ${error.message}`); appdb.update(appId, { installationState: appdb.ISTATE_ERROR, errorMessage: error.message, taskId: null }, NOOP_CALLBACK); + } else { + appdb.update(appId, { taskId: null }, NOOP_CALLBACK); } }); diff --git a/src/apptask.js b/src/apptask.js index 860d6aebc..9c6b30048 100644 --- a/src/apptask.js +++ b/src/apptask.js @@ -589,11 +589,11 @@ function install(app, restoreConfig, progressCallback, callback) { configureReverseProxy.bind(null, app), progressCallback.bind(null, { percent: 100, message: 'Done' }), - updateApp.bind(null, app, { installationState: appdb.ISTATE_INSTALLED, health: null, taskId: null }) + updateApp.bind(null, app, { installationState: appdb.ISTATE_INSTALLED, health: null }) ], function seriesDone(error) { if (error) { debugApp(app, 'error installing app: %s', error); - return updateApp(app, { installationState: appdb.ISTATE_ERROR, errorMessage: error.message, taskId: null }, callback.bind(null, error)); + return updateApp(app, { installationState: appdb.ISTATE_ERROR, errorMessage: error.message }, callback.bind(null, error)); } callback(null); }); @@ -611,11 +611,11 @@ function backup(app, progressCallback, callback) { }), progressCallback.bind(null, { percent: 100, message: 'Done' }), - updateApp.bind(null, app, { installationState: appdb.ISTATE_INSTALLED, errorMessage: '', taskId: null }) + updateApp.bind(null, app, { installationState: appdb.ISTATE_INSTALLED, errorMessage: '' }) ], function seriesDone(error) { if (error) { debugApp(app, 'error backing up app: %s', error); - return updateApp(app, { installationState: appdb.ISTATE_INSTALLED, errorMessage: error.message, taskId: null }, callback.bind(null, error)); // return to installed state intentionally + return updateApp(app, { installationState: appdb.ISTATE_INSTALLED, errorMessage: error.message }, callback.bind(null, error)); // return to installed state intentionally } callback(null); }); @@ -692,11 +692,11 @@ function configure(app, oldConfig, progressCallback, callback) { configureReverseProxy.bind(null, app), progressCallback.bind(null, { percent: 100, message: 'Done' }), - updateApp.bind(null, app, { installationState: appdb.ISTATE_INSTALLED, errorMessage: '', health: null, taskId: null }) + updateApp.bind(null, app, { installationState: appdb.ISTATE_INSTALLED, errorMessage: '', health: null }) ], function seriesDone(error) { if (error) { debugApp(app, 'error reconfiguring : %s', error); - return updateApp(app, { installationState: appdb.ISTATE_ERROR, errorMessage: error.message, taskId: null }, callback.bind(null, error)); + return updateApp(app, { installationState: appdb.ISTATE_ERROR, errorMessage: error.message }, callback.bind(null, error)); } callback(null); }); @@ -799,11 +799,11 @@ function update(app, updateConfig, progressCallback, callback) { runApp.bind(null, app, progressCallback), progressCallback.bind(null, { percent: 100, message: 'Done' }), - updateApp.bind(null, app, { installationState: appdb.ISTATE_INSTALLED, errorMessage: '', health: null, taskId: null, updateTime: new Date() }) + updateApp.bind(null, app, { installationState: appdb.ISTATE_INSTALLED, errorMessage: '', health: null, updateTime: new Date() }) ], function seriesDone(error) { if (error && error.backupError) { debugApp(app, 'update aborted because backup failed', error); - updateApp(app, { installationState: appdb.ISTATE_INSTALLED, errorMessage: '', health: null, taskId: null }, callback.bind(null, error)); + updateApp(app, { installationState: appdb.ISTATE_INSTALLED, errorMessage: '', health: null }, callback.bind(null, error)); } else if (error) { debugApp(app, 'Error updating app: %s', error); updateApp(app, { installationState: appdb.ISTATE_ERROR, errorMessage: error.message, updateTime: new Date() }, callback.bind(null, error)); @@ -860,7 +860,7 @@ function uninstall(app, progressCallback, callback) { ], function seriesDone(error) { if (error) { debugApp(app, 'error uninstalling app: %s', error); - return updateApp(app, { installationState: appdb.ISTATE_ERROR, errorMessage: error.message, taskId: null }, callback.bind(null, error)); + return updateApp(app, { installationState: appdb.ISTATE_ERROR, errorMessage: error.message }, callback.bind(null, error)); } callback(null); });