get previous du task if any

This commit is contained in:
Girish Ramakrishnan
2022-11-09 15:04:21 +01:00
parent 4e35df5567
commit e15024f46c
2 changed files with 38 additions and 21 deletions

View File

@@ -1317,21 +1317,6 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
});
};
Client.prototype.waitForTask = function (taskId, callback) {
var that = this;
function checkTask() {
that.getTask(taskId, function (error, result) {
if (error) return callback(error);
if (result.pending || result.active) return setTimeout(checkTask, 1000);
callback(result.error, result.result);
});
}
checkTask();
};
Client.prototype.getTask = function (taskId, callback) {
get('/api/v1/tasks/' + taskId, null, function (error, data, status) {
if (error) return callback(error);
@@ -1982,7 +1967,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
if (error) return callback(error);
if (status !== 201) return callback(new ClientError(status, data));
that.waitForTask(data.taskId, callback);
callback(null, data.taskId);
});
};