Return args as part of task.get

the ui needs this to repair any failed app task
This commit is contained in:
Girish Ramakrishnan
2019-11-23 18:06:31 -08:00
parent f543b98764
commit 6774514bd2
3 changed files with 4 additions and 11 deletions
+3
View File
@@ -648,6 +648,9 @@ function checkAppState(app, state) {
if (app.taskId) return new BoxError(BoxError.BAD_STATE, `Not allowed in this app state : ${app.installationState} / ${app.runState}`);
if (app.installationState === exports.ISTATE_ERROR) {
if (app.error.installationState === state) return null;
// allow uninstall from any state
if (state !== exports.ISTATE_PENDING_UNINSTALL) return new BoxError(BoxError.BAD_STATE, 'Not allowed in error state');
}
+1 -3
View File
@@ -31,7 +31,7 @@ function get(req, res, next) {
tasks.get(req.params.taskId, function (error, task) {
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(200, tasks.removePrivateFields(task)));
next(new HttpSuccess(200, task));
});
}
@@ -47,8 +47,6 @@ function list(req, res, next) {
tasks.listByTypePaged(req.query.type || null, page, perPage, function (error, result) {
if (error) return next(BoxError.toHttpError(error));
result = result.map(tasks.removePrivateFields);
next(new HttpSuccess(200, { tasks: result }));
});
}
-8
View File
@@ -14,8 +14,6 @@ exports = module.exports = {
stopTask: stopTask,
stopAllTasks: stopAllTasks,
removePrivateFields: removePrivateFields,
// task types. if you add a task here, fill up the function table in taskworker
TASK_APP: 'app',
TASK_BACKUP: 'backup',
@@ -269,9 +267,3 @@ function getLogs(taskId, options, callback) {
callback(null, transformStream);
}
// removes all fields that are strictly private and should never be returned by API calls
function removePrivateFields(task) {
var result = _.pick(task, 'id', 'type', 'percent', 'message', 'error', 'active', 'creationTime', 'result', 'ts', 'success');
return result;
}