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