From ba57282879a6880787f039539ac2764a70047466 Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 27 Jun 2023 22:19:06 +0200 Subject: [PATCH] Re-add task timeout --- Tranga/TaskManager.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Tranga/TaskManager.cs b/Tranga/TaskManager.cs index 3a3079a..aca744b 100644 --- a/Tranga/TaskManager.cs +++ b/Tranga/TaskManager.cs @@ -82,6 +82,14 @@ public class TaskManager break; } } + + foreach (TrangaTask timedOutTask in _allTasks + .Where(taskQuery => taskQuery.lastChange.Add(TimeSpan.FromMinutes(3)) < DateTime.Now)) + { + if(timedOutTask is DownloadChapterTask dct) + _runningDownloadChapterTasks[dct].Cancel(); + timedOutTask.state = TrangaTask.ExecutionState.Failed; + } foreach (TrangaTask failedDownloadChapterTask in _allTasks.Where(taskQuery => taskQuery.state is TrangaTask.ExecutionState.Failed && taskQuery is DownloadChapterTask).ToArray())