From 47a80d67a8c879a3f78f37c91a678d3eece2d2fe Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 27 Jun 2023 23:55:13 +0200 Subject: [PATCH] TrangaTask Success-State and child task deletion --- Tranga/TrangaTask.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Tranga/TrangaTask.cs b/Tranga/TrangaTask.cs index faf5fb4..35b8a7e 100644 --- a/Tranga/TrangaTask.cs +++ b/Tranga/TrangaTask.cs @@ -94,26 +94,25 @@ public abstract class TrangaTask nm.SendNotification("Chapter downloaded", $"{dct.publication.sortName} {dct.chapter.chapterNumber} {dct.chapter.name}"); break; } - - foreach(TrangaTask childTask in this.childTasks.ToArray()) - taskManager.DeleteTask(childTask); + if ((int)statusCode >= 200 && (int)statusCode < 300) { this.lastExecuted = DateTime.Now; - if (this is DownloadChapterTask) + if(this is DownloadChapterTask) this.state = ExecutionState.Success; else this.state = ExecutionState.Waiting; } else { - if (this is DownloadChapterTask && statusCode == HttpStatusCode.NotFound) - this.state = ExecutionState.Success; - else - this.state = ExecutionState.Failed; + this.state = ExecutionState.Failed; this.lastExecuted = DateTime.MaxValue; } + + foreach (TrangaTask childTask in this.childTasks.Where(ct => ct is DownloadChapterTask).ToArray()) + taskManager.DeleteTask(childTask); + logger?.WriteLine(this.GetType().ToString(), $"Finished Executing Task {this}"); }