From 7800b4819364f60e76a0ffe68b812a73741672c6 Mon Sep 17 00:00:00 2001 From: rlauu <46294892+rlauu@users.noreply.github.com> Date: Sat, 20 Apr 2024 14:50:40 +0200 Subject: [PATCH] more progress bar fixes --- .../ScheduledTasks/BaseItemAnalyzerTask.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/BaseItemAnalyzerTask.cs b/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/BaseItemAnalyzerTask.cs index cc3bdf1..866cf98 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/BaseItemAnalyzerTask.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/BaseItemAnalyzerTask.cs @@ -88,6 +88,7 @@ public class BaseItemAnalyzerTask } var totalProcessed = 0; + var modeCount = _analysisModes.Count; var options = new ParallelOptions() { MaxDegreeOfParallelism = Plugin.Instance!.Configuration.MaxParallelism @@ -103,23 +104,35 @@ public class BaseItemAnalyzerTask season.Value.AsReadOnly(), _analysisModes); - if (episodes.Count == 0) + var episodeCount = episodes.Count; + + if (episodeCount == 0) { return; } var first = episodes[0]; + var requiredModeCount = requiredModes.Count; - if (requiredModes.Count == 0) + if (requiredModeCount == 0) { _logger.LogDebug( "All episodes in {Name} season {Season} have already been analyzed", first.SeriesName, first.SeasonNumber); + + Interlocked.Add(ref totalProcessed, (episodeCount * modeCount)); // Update totalProcessed directly + progress.Report((totalProcessed * 100) / totalQueued); return; } + if (modeCount != requiredModeCount) + { + Interlocked.Add(ref totalProcessed, episodeCount); + progress.Report((totalProcessed * 100) / totalQueued); // Partial analysis some modes have already been analyzed + } + try { if (cancellationToken.IsCancellationRequested)