mirror of
https://github.com/C9Glax/tranga-website.git
synced 2025-06-12 23:07:54 +02:00
Better way of handling progress, and childProgress.
More reliable taskFinishTime
This commit is contained in:
@ -11,6 +11,7 @@ public class DownloadChapterTask : TrangaTask
|
||||
public Chapter chapter { get; }
|
||||
[JsonIgnore]public DownloadNewChaptersTask? parentTask { get; set; }
|
||||
public string? parentTaskId { get; set; }
|
||||
[JsonIgnore]public new double progress { get; private set; }
|
||||
|
||||
|
||||
public DownloadChapterTask(Task task, string connectorName, Publication publication, Chapter chapter, string language = "en", DownloadNewChaptersTask? parentTask = null) : base(task, TimeSpan.Zero)
|
||||
@ -21,6 +22,7 @@ public class DownloadChapterTask : TrangaTask
|
||||
this.language = language;
|
||||
this.parentTask = parentTask;
|
||||
this.parentTaskId = parentTask?.taskId;
|
||||
this.progress = 0;
|
||||
}
|
||||
|
||||
protected override void ExecuteTask(TaskManager taskManager, Logger? logger, CancellationToken? cancellationToken = null)
|
||||
|
@ -8,15 +8,11 @@ public class DownloadNewChaptersTask : TrangaTask
|
||||
public string connectorName { get; }
|
||||
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)
|
||||
{
|
||||
this.connectorName = connectorName;
|
||||
this.publication = publication;
|
||||
this.language = language;
|
||||
this.childTasks = new();
|
||||
}
|
||||
|
||||
protected override void ExecuteTask(TaskManager taskManager, Logger? logger, CancellationToken? cancellationToken = null)
|
||||
@ -41,19 +37,6 @@ public class DownloadNewChaptersTask : TrangaTask
|
||||
this.childTasks.Add(newTask);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public void AddChildTask(DownloadChapterTask childTask)
|
||||
{
|
||||
this.childTasks.Add(childTask);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the available Chapters of a Publication
|
||||
|
@ -14,6 +14,6 @@ public class UpdateLibrariesTask : TrangaTask
|
||||
return;
|
||||
foreach(LibraryManager lm in taskManager.settings.libraryManagers)
|
||||
lm.UpdateLibrary();
|
||||
this.progress = 1f;
|
||||
IncrementProgress(1);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user