Simplify max bucket fingerprint retrieval

This commit is contained in:
ConfusedPolarBear 2022-07-08 23:21:07 -05:00
parent 0d69c3a9d5
commit 259bddfc1a

View File

@ -788,29 +788,13 @@ public class FingerprinterTask : IScheduledTask
var goodFingerprints = new List<ReadOnlyCollection<uint>>();
foreach (var id in maxBucket.Episodes)
{
// Sometimes an episode isn't in the fingerprint cache. When this occurs, it has to be fingerprinted again.
_logger.LogTrace("Second pass: searching cache for {Id}", id);
if (!_fingerprintCache.TryGetValue(id, out var fp))
{
_logger.LogTrace("Second pass: max bucket episode {Id} not in cache, skipping", id);
continue;
}
if (_fingerprintCache.ContainsKey(id))
{
_logger.LogTrace("Second pass: cache hit for {Id}", id);
goodFingerprints.Add(_fingerprintCache[id]);
}
else
{
_logger.LogTrace("Second pass: cache miss for {Id}", id);
var fullEp = episodes.Find((e) => { return e.EpisodeId == id; });
if (fullEp is not null)
{
goodFingerprints.Add(Chromaprint.Fingerprint(fullEp));
}
else
{
_logger.LogTrace("Second pass: unable to find episode {Id}", id);
}
}
goodFingerprints.Add(fp);
}
foreach (var episode in episodes)