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

@ -36,14 +36,6 @@ public class DownloadChapterTask : TrangaTask
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()
{
return $"{base.ToString()}, {connectorName}, {publication.sortName} {publication.internalId}, Vol.{chapter.volumeNumber} Ch.{chapter.chapterNumber}";

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)
{
@ -18,20 +19,6 @@ public class DownloadNewChaptersTask : TrangaTask
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)
{
if (cancellationToken?.IsCancellationRequested??false)