fix bug that task would not retry when the previous task failed to retry

This commit is contained in:
MaysWind 2019-08-03 02:25:29 +08:00
parent 8e9ecce36b
commit e549b7e3ae

View file

@ -741,6 +741,8 @@
var failedCount = 0; var failedCount = 0;
var doRetryFunc = function (task, index) { var doRetryFunc = function (task, index) {
ariaNgLogService.debug('[aria2TaskService.retryTasks] task#' + index + ', gid=' + task.gid + ' start retrying', task);
return retryTaskFunc(task.gid, function (response) { return retryTaskFunc(task.gid, function (response) {
ariaNgLogService.debug('[aria2TaskService.retryTasks] task#' + index + ', gid=' + task.gid + ', result=' + response.success, task); ariaNgLogService.debug('[aria2TaskService.retryTasks] task#' + index + ', gid=' + task.gid + ', result=' + response.success, task);
@ -772,7 +774,9 @@
currentPromise = doRetryFunc(task, i); currentPromise = doRetryFunc(task, i);
} else { } else {
currentPromise = (function (task, index) { currentPromise = (function (task, index) {
return lastPromise.then(function () { return lastPromise.then(function onSuccess() {
return doRetryFunc(task, index);
}).catch(function onError() {
return doRetryFunc(task, index); return doRetryFunc(task, index);
}); });
})(task, i); })(task, i);