diff --git a/Tranga/TrangaTask.cs b/Tranga/TrangaTask.cs index f2b2ed1..b7402e3 100644 --- a/Tranga/TrangaTask.cs +++ b/Tranga/TrangaTask.cs @@ -76,11 +76,8 @@ public abstract class TrangaTask public void ReplaceFailedChildTask(DownloadChapterTask failed, DownloadChapterTask newTask) { - if (!this.childTasks.Contains(failed)) - throw new ArgumentException($"Task {failed} is not childTask of {this}"); - this.childTasks.Remove(failed); - this.childTasks.Add(newTask); - this.DecrementProgress(failed.progress); + this.RemoveChildTask(failed); + this.AddChildTask(newTask); } public void AddChildTask(TrangaTask childTask) @@ -88,6 +85,12 @@ public abstract class TrangaTask this.childTasks.Add(childTask); } + public void RemoveChildTask(TrangaTask childTask) + { + this.childTasks.Remove(childTask); + this.DecrementProgress(childTask.progress); + } + public void IncrementProgress(double amount) { this.lastChange = DateTime.Now;