Start parallel rewrite

This commit is contained in:
ConfusedPolarBear 2022-05-13 01:28:06 -05:00
parent 3370f1058d
commit 56fdbef0ec

View File

@ -86,6 +86,20 @@ public class FingerprinterTask : IScheduledTask
var totalProcessed = 0;
foreach (var season in queue)
{
AnalyzeSeason(season, cancellationToken);
// TODO: report progress on a per episode basis
totalProcessed += season.Value.Count;
progress.Report((totalProcessed * 100) / Plugin.Instance!.TotalQueued);
}
return Task.CompletedTask;
}
private void AnalyzeSeason(
KeyValuePair<Guid, List<QueuedEpisode>> season,
CancellationToken cancellationToken)
{
var first = season.Value[0];
@ -95,7 +109,7 @@ public class FingerprinterTask : IScheduledTask
*/
if (season.Value.Count < 2 || first.SeasonNumber == 0)
{
continue;
return;
}
_logger.LogInformation(
@ -144,8 +158,11 @@ public class FingerprinterTask : IScheduledTask
lhs.EpisodeId,
rhs.EpisodeId);
/*
TODO: bring back
totalProcessed += 2;
progress.Report((totalProcessed * 100) / Plugin.Instance!.TotalQueued);
*/
continue;
}
@ -173,30 +190,25 @@ public class FingerprinterTask : IScheduledTask
}
finally
{
/*
TODO: bring back
totalProcessed += 2;
progress.Report((totalProcessed * 100) / Plugin.Instance!.TotalQueued);
*/
}
}
Plugin.Instance!.SaveTimestamps();
if (cancellationToken.IsCancellationRequested)
if (cancellationToken.IsCancellationRequested || !everFoundIntro)
{
break;
}
if (!everFoundIntro)
{
continue;
return;
}
// Reanalyze this season to check for (and hopefully correct) outliers and failed episodes.
CheckSeason(season.Value);
}
return Task.CompletedTask;
}
/// <summary>
/// Analyze two episodes to find an introduction sequence shared between them.
/// </summary>