Fix bug where ChildTasks hung parentTasks

This commit is contained in:
glax 2023-06-24 21:00:26 +02:00
parent 7b311eae75
commit 604abd5f9a
2 changed files with 5 additions and 6 deletions

View File

@ -333,17 +333,16 @@ public class TaskManager
this._allTasks = JsonConvert.DeserializeObject<HashSet<TrangaTask>>(buffer, new JsonSerializerSettings() { Converters = { new TrangaTask.TrangaTaskJsonConverter() } })!;
}
foreach (TrangaTask task in this._allTasks.Where(tTask => tTask.parentTaskId is not null))
foreach (TrangaTask task in this._allTasks.Where(tTask => tTask.parentTaskId is not null).ToArray())
{
TrangaTask? parentTask = this._allTasks.FirstOrDefault(pTask => pTask.taskId == task.parentTaskId);
if (parentTask is not null)
{
task.parentTask = parentTask;
parentTask.AddChildTask(task);
this.DeleteTask(task);
parentTask.lastExecuted = DateTime.UnixEpoch;
}
}
if (File.Exists(settings.knownPublicationsPath))
{
logger?.WriteLine(this.GetType().ToString(), $"Importing known publications from {settings.knownPublicationsPath}");

View File

@ -72,7 +72,7 @@ public abstract class TrangaTask
this.state = ExecutionState.Running;
this.executionStarted = DateTime.Now;
this.lastChange = DateTime.Now;
if(parentTask is not null && parentTask.childTasks.All(ct => ct.state is ExecutionState.Waiting))
if(parentTask is not null && parentTask.childTasks.All(ct => ct.state is ExecutionState.Waiting or ExecutionState.Failed))
parentTask.executionStarted = DateTime.Now;
HttpStatusCode statusCode = ExecuteTask(taskManager, logger, cancellationToken);