diff --git a/Tranga/Jobs/Job.cs b/Tranga/Jobs/Job.cs index f007850..d565ec1 100644 --- a/Tranga/Jobs/Job.cs +++ b/Tranga/Jobs/Job.cs @@ -59,13 +59,15 @@ public abstract class Job : GlobalBase public void ResetProgress() { this.progressToken = new ProgressToken(this.progressToken.increments); + this.lastExecution = DateTime.Now; } public void Cancel() { Log($"Cancelling {this}"); this.progressToken.cancellationRequested = true; - this.progressToken.Complete(); + this.progressToken.Cancel(); + this.lastExecution = DateTime.Now; if(subJobs is not null) foreach(Job subJob in subJobs) subJob.Cancel(); diff --git a/Tranga/Jobs/JobBoss.cs b/Tranga/Jobs/JobBoss.cs index fa8cafe..39e5c43 100644 --- a/Tranga/Jobs/JobBoss.cs +++ b/Tranga/Jobs/JobBoss.cs @@ -146,6 +146,20 @@ public class JobBoss : GlobalBase jobQueue.Dequeue(); }else if(queueHead.progressToken.state is ProgressToken.State.Standby) AddJobsToQueue(jobQueue.Peek().ExecuteReturnSubTasks()); + else if (queueHead.progressToken.state is ProgressToken.State.Cancelled) + { + switch (queueHead) + { + case DownloadChapter: + RemoveJob(queueHead); + break; + case DownloadNewChapters: + if(queueHead.recurring) + queueHead.progressToken.Complete(); + break; + } + jobQueue.Dequeue(); + } } } } \ No newline at end of file diff --git a/Tranga/Jobs/ProgressToken.cs b/Tranga/Jobs/ProgressToken.cs index 9b534a8..5661403 100644 --- a/Tranga/Jobs/ProgressToken.cs +++ b/Tranga/Jobs/ProgressToken.cs @@ -7,7 +7,7 @@ public class ProgressToken public int incrementsCompleted { get; set; } public float progress => GetProgress(); - public enum State { Running, Complete, Standby } + public enum State { Running, Complete, Standby, Cancelled } public State state { get; private set; } public ProgressToken(int increments) @@ -41,4 +41,9 @@ public class ProgressToken { state = State.Complete; } + + public void Cancel() + { + state = State.Cancelled; + } } \ No newline at end of file