Skip to content

Commit

Permalink
more progress bar fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rlauuzo authored and AbandonedCart committed Apr 20, 2024
1 parent 250c8ac commit 7800b48
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public class BaseItemAnalyzerTask
}

var totalProcessed = 0;
var modeCount = _analysisModes.Count;
var options = new ParallelOptions()
{
MaxDegreeOfParallelism = Plugin.Instance!.Configuration.MaxParallelism
Expand All @@ -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)
Expand Down

0 comments on commit 7800b48

Please sign in to comment.