Redid progress calcuation on DownloadNewChaptersTask and DownloadChapterTask
This commit is contained in:
parent
c8e27921ab
commit
d5c9c5ba96
@ -35,7 +35,7 @@ public abstract class TrangaTask
|
|||||||
[Newtonsoft.Json.JsonIgnore]
|
[Newtonsoft.Json.JsonIgnore]
|
||||||
public TimeSpan executionApproximatelyRemaining => this.executionApproximatelyFinished.Subtract(DateTime.Now);
|
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
|
public enum ExecutionState
|
||||||
{
|
{
|
||||||
|
@ -36,14 +36,6 @@ public class DownloadChapterTask : TrangaTask
|
|||||||
taskManager.DeleteTask(this);
|
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()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return $"{base.ToString()}, {connectorName}, {publication.sortName} {publication.internalId}, Vol.{chapter.volumeNumber} Ch.{chapter.chapterNumber}";
|
return $"{base.ToString()}, {connectorName}, {publication.sortName} {publication.internalId}, Vol.{chapter.volumeNumber} Ch.{chapter.chapterNumber}";
|
||||||
|
@ -9,6 +9,7 @@ public class DownloadNewChaptersTask : TrangaTask
|
|||||||
public Publication publication { get; }
|
public Publication publication { get; }
|
||||||
public string language { get; }
|
public string language { get; }
|
||||||
[JsonIgnore]private HashSet<DownloadChapterTask> childTasks { 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)
|
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();
|
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)
|
protected override void ExecuteTask(TaskManager taskManager, Logger? logger, CancellationToken? cancellationToken = null)
|
||||||
{
|
{
|
||||||
if (cancellationToken?.IsCancellationRequested??false)
|
if (cancellationToken?.IsCancellationRequested??false)
|
||||||
|
Loading…
Reference in New Issue
Block a user