Redid progress calcuation on DownloadNewChaptersTask and DownloadChapterTask

This commit is contained in:
glax 2023-06-10 16:00:16 +02:00
parent c8e27921ab
commit d5c9c5ba96
3 changed files with 2 additions and 23 deletions

View File

@ -35,7 +35,7 @@ public abstract class TrangaTask
[Newtonsoft.Json.JsonIgnore]
public TimeSpan executionApproximatelyRemaining => this.executionApproximatelyFinished.Subtract(DateTime.Now);
[Newtonsoft.Json.JsonIgnore]public DateTime lastChange { get; protected set; }
[Newtonsoft.Json.JsonIgnore]public DateTime lastChange { get; private set; }
public enum ExecutionState
{

View File

@ -35,14 +35,6 @@ public class DownloadChapterTask : TrangaTask
this.parentTask.state = ExecutionState.Waiting;
taskManager.DeleteTask(this);
}
public new float IncrementProgress(float amount)
{
this.progress += amount;
this.lastChange = DateTime.Now;
parentTask?.IncrementProgress(amount);
return this.progress;
}
public override string ToString()
{

View File

@ -9,6 +9,7 @@ public class DownloadNewChaptersTask : TrangaTask
public Publication publication { get; }
public string language { get; }
[JsonIgnore]private HashSet<DownloadChapterTask> childTasks { get; }
[JsonIgnore]public new double progress => childTasks.Count > 0 ? childTasks.Sum(childTask => childTask.progress) / childTasks.Count : 0;
public DownloadNewChaptersTask(Task task, string connectorName, Publication publication, TimeSpan reoccurrence, string language = "en") : base(task, reoccurrence)
{
@ -17,20 +18,6 @@ public class DownloadNewChaptersTask : TrangaTask
this.language = language;
this.childTasks = new();
}
public new float IncrementProgress(float amount)
{
this.progress += amount / this.childTasks.Count;
this.lastChange = DateTime.Now;
return this.progress;
}
public new float DecrementProgress(float amount)
{
this.progress -= amount / this.childTasks.Count;
this.lastChange = DateTime.Now;
return this.progress;
}
protected override void ExecuteTask(TaskManager taskManager, Logger? logger, CancellationToken? cancellationToken = null)
{