Ensure no duplicate Ids are permitted

This commit is contained in:
rlauuzo 2024-05-08 16:42:56 +02:00 committed by GitHub
parent fe60457091
commit 7ea26e8fea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -191,6 +191,19 @@ public class QueueManager
return;
}
// Allocate a new list for each new season
_queuedEpisodes.TryAdd(episode.SeasonId, new List<QueuedEpisode>());
if (_queuedEpisodes[episode.SeasonId].Any(e => e.EpisodeId == episode.Id))
{
_logger.LogDebug(
"\"{Name}\" from series \"{Series}\" ({Id}) is already queued",
episode.Name,
episode.SeriesName,
episode.Id);
return;
}
// Limit analysis to the first X% of the episode and at most Y minutes.
// X and Y default to 25% and 10 minutes.
var duration = TimeSpan.FromTicks(episode.RunTimeTicks ?? 0).TotalSeconds;
@ -205,9 +218,6 @@ public class QueueManager
fingerprintDuration,
60 * Plugin.Instance.Configuration.AnalysisLengthLimit);
// Allocate a new list for each new season
_queuedEpisodes.TryAdd(episode.SeasonId, new List<QueuedEpisode>());
// Queue the episode for analysis
var maxCreditsDuration = Plugin.Instance.Configuration.MaximumCreditsDuration;
_queuedEpisodes[episode.SeasonId].Add(new QueuedEpisode