2
0

Fix deletion of successful child tasks

This commit is contained in:
glax 2023-06-21 16:53:41 +02:00
parent 7e4f43f1e2
commit 8737617e5f
2 changed files with 7 additions and 11 deletions

View File

@ -82,9 +82,8 @@ public class TaskManager
}
}
TrangaTask[] failedDownloadChapterTasks = _allTasks.Where(taskQuery =>
taskQuery.state is TrangaTask.ExecutionState.Failed && taskQuery is DownloadChapterTask).ToArray();
foreach (TrangaTask failedDownloadChapterTask in failedDownloadChapterTasks)
foreach (TrangaTask failedDownloadChapterTask in _allTasks.Where(taskQuery =>
taskQuery.state is TrangaTask.ExecutionState.Failed && taskQuery is DownloadChapterTask).ToArray())
{
DeleteTask(failedDownloadChapterTask);
TrangaTask newTask = failedDownloadChapterTask.Clone();
@ -92,13 +91,6 @@ public class TaskManager
AddTask(newTask);
}
TrangaTask[] successfulDownloadChapterTasks = _allTasks.Where(taskQuery =>
taskQuery.state is TrangaTask.ExecutionState.Success && taskQuery is DownloadChapterTask).ToArray();
foreach(TrangaTask successfulDownloadChapterTask in successfulDownloadChapterTasks)
{
DeleteTask(successfulDownloadChapterTask);
}
if(waitingTasksCount != _allTasks.Count(task => task.state is TrangaTask.ExecutionState.Waiting))
ExportDataAndSettings();
waitingTasksCount = _allTasks.Count(task => task.state is TrangaTask.ExecutionState.Waiting);
@ -166,6 +158,8 @@ public class TaskManager
_runningDownloadChapterTasks[cRemoveTask].Cancel();
_runningDownloadChapterTasks.Remove(cRemoveTask);
}
foreach(TrangaTask childTask in removeTask.childTasks)
DeleteTask(childTask);
}
public IEnumerable<TrangaTask> GetTasksMatching(TrangaTask.Task taskType, string? connectorName = null, string? searchString = null, string? internalId = null, string? chapterSortNumber = null)

View File

@ -75,6 +75,8 @@ public abstract class TrangaTask
HttpStatusCode statusCode = ExecuteTask(taskManager, logger, cancellationToken);
while(childTasks.Any(ct => ct.state is ExecutionState.Enqueued or ExecutionState.Running))
Thread.Sleep(1000);
foreach(TrangaTask childTask in this.childTasks.ToArray())
taskManager.DeleteTask(childTask);
if ((int)statusCode >= 200 && (int)statusCode < 300)
{
this.lastExecuted = DateTime.Now;