Check cancellation token

This commit is contained in:
ConfusedPolarBear 2022-09-02 23:42:32 -05:00
parent cf99dde0e2
commit 7612e6cdaf

View File

@ -126,8 +126,7 @@ public class AnalyzeEpisodesTask : IScheduledTask
// Log EDL settings
EdlManager.LogConfiguration();
// Include the previously processed episodes in the percentage reported to the UI.
var totalProcessed = CountProcessedEpisodes();
var totalProcessed = 0;
var options = new ParallelOptions()
{
MaxDegreeOfParallelism = Plugin.Instance!.Configuration.MaxParallelism
@ -151,6 +150,11 @@ public class AnalyzeEpisodesTask : IScheduledTask
try
{
if (cancellationToken.IsCancellationRequested)
{
return;
}
var episodes = new ReadOnlyCollection<QueuedEpisode>(season.Value);
// Increment totalProcessed by the number of episodes in this season that were actually analyzed
@ -268,6 +272,11 @@ public class AnalyzeEpisodesTask : IScheduledTask
try
{
fingerprintCache[episode.EpisodeId] = FFmpegWrapper.Fingerprint(episode);
if (cancellationToken.IsCancellationRequested)
{
return episodes.Count;
}
}
catch (FingerprintException ex)
{
@ -324,6 +333,11 @@ public class AnalyzeEpisodesTask : IScheduledTask
// If no intro is found at this point, the popped episode is not reinserted into the queue.
}
if (cancellationToken.IsCancellationRequested)
{
return episodes.Count;
}
// Adjust all introduction end times so that they end at silence.
seasonIntros = AdjustIntroEndTimes(episodes, seasonIntros);