Fix installation states

App operations can only be done in 'installed' or 'error' state.
If some other operation is in progress, you have to cancel it first.

This guarantees that the old app command got killed.
This commit is contained in:
Girish Ramakrishnan
2019-08-29 09:10:39 -07:00
parent 1faee00764
commit f3008064e4
4 changed files with 42 additions and 36 deletions

View File

@@ -276,6 +276,7 @@ function uninstallApp(req, res, next) {
apps.uninstall(req.params.id, auditSource.fromRequest(req), function (error, result) {
if (error && error.reason === AppsError.EXTERNAL_ERROR) return next(new HttpError(424, error));
if (error && error.reason === AppsError.BAD_STATE) return next(new HttpError(409, error.message));
if (error && error.reason === AppsError.NOT_FOUND) return next(new HttpError(404, 'No such app'));
if (error) return next(new HttpError(500, error));