kopia lustrzana https://github.com/OpenDroneMap/NodeODM
Added ability to change task options during restart
rodzic
c7413f04b9
commit
afb7469c75
|
@ -224,7 +224,7 @@ _required_|UUID of the task|string|
|
|||
=== POST /task/restart
|
||||
|
||||
==== Description
|
||||
Restarts a task that was previously canceled or that had failed to process
|
||||
Restarts a task that was previously canceled, that had failed to process or that successfully completed
|
||||
|
||||
|
||||
==== Parameters
|
||||
|
@ -232,6 +232,8 @@ Restarts a task that was previously canceled or that had failed to process
|
|||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
||||
|===
|
||||
|Type|Name|Description|Schema|Default
|
||||
|*Body*|*options* +
|
||||
_optional_|Serialized JSON string of the options to use for processing, as an array of the format: [{name: option1, value: value1}, {name: option2, value: value2}, …]. For example, [{"name":"cmvs-maxImages","value":"500"},{"name":"time","value":true}]. For a list of all options, call /options. Overrides the previous options set for this task.|string|
|
||||
|*Body*|*uuid* +
|
||||
_required_|UUID of the task|string|
|
||||
|===
|
||||
|
|
File diff suppressed because one or more lines are too long
23
index.js
23
index.js
|
@ -482,7 +482,7 @@ app.post('/task/remove', uuidCheck, (req, res) => {
|
|||
/** @swagger
|
||||
* /task/restart:
|
||||
* post:
|
||||
* description: Restarts a task that was previously canceled or that had failed to process
|
||||
* description: Restarts a task that was previously canceled, that had failed to process or that successfully completed
|
||||
* parameters:
|
||||
* -
|
||||
* name: uuid
|
||||
|
@ -491,14 +491,31 @@ app.post('/task/remove', uuidCheck, (req, res) => {
|
|||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* -
|
||||
* name: options
|
||||
* in: body
|
||||
* description: 'Serialized JSON string of the options to use for processing, as an array of the format: [{name: option1, value: value1}, {name: option2, value: value2}, ...]. For example, [{"name":"cmvs-maxImages","value":"500"},{"name":"time","value":true}]. For a list of all options, call /options. Overrides the previous options set for this task.'
|
||||
* required: false
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Command Received
|
||||
* schema:
|
||||
* $ref: "#/definitions/Response"
|
||||
*/
|
||||
app.post('/task/restart', uuidCheck, (req, res) => {
|
||||
taskManager.restart(req.body.uuid, successHandler(res));
|
||||
app.post('/task/restart', uuidCheck, (req, res, next) => {
|
||||
if (req.body.options){
|
||||
odmOptions.filterOptions(req.body.options, (err, options) => {
|
||||
if (err) res.json({ error: err.message });
|
||||
else {
|
||||
req.body.options = options;
|
||||
next();
|
||||
}
|
||||
});
|
||||
} else next();
|
||||
}, (req, res) => {
|
||||
taskManager.restart(req.body.uuid, req.body.options, successHandler(res));
|
||||
});
|
||||
|
||||
/** @swagger
|
||||
|
|
|
@ -392,12 +392,13 @@ module.exports = class Task{
|
|||
|
||||
// Re-executes the task (by setting it's state back to QUEUED)
|
||||
// Only tasks that have been canceled, completed or have failed can be restarted.
|
||||
restart(cb){
|
||||
restart(options, cb){
|
||||
if ([statusCodes.CANCELED, statusCodes.FAILED, statusCodes.COMPLETED].indexOf(this.status.code) !== -1){
|
||||
this.setStatus(statusCodes.QUEUED);
|
||||
this.dateCreated = new Date().getTime();
|
||||
this.output = [];
|
||||
this.stopTrackingProcessingTime(true);
|
||||
if (options !== undefined) this.options = options;
|
||||
cb(null);
|
||||
}else{
|
||||
cb(new Error("Task cannot be restarted"));
|
||||
|
|
|
@ -230,10 +230,11 @@ module.exports = class TaskManager{
|
|||
|
||||
// Restarts (puts back into QUEUED state)
|
||||
// a task that is either in CANCELED or FAILED state.
|
||||
restart(uuid, cb){
|
||||
// When options is set, the task's options are overriden
|
||||
restart(uuid, options, cb){
|
||||
let task = this.find(uuid, cb);
|
||||
if (task){
|
||||
task.restart(err => {
|
||||
task.restart(options, err => {
|
||||
if (!err) this.processNextTask();
|
||||
cb(err);
|
||||
});
|
||||
|
|
|
@ -125,7 +125,7 @@ module.exports = {
|
|||
// @param options[]
|
||||
filterOptions: function(options, done){
|
||||
assert(odmOptions !== null, "odmOptions is not set. Have you initialized odmOptions properly?");
|
||||
|
||||
|
||||
try{
|
||||
if (typeof options === "string") options = JSON.parse(options);
|
||||
if (!Array.isArray(options)) options = [];
|
||||
|
|
Ładowanie…
Reference in New Issue