From e68780d0ff3cb07ccbfc200bbd84fcee04796419 Mon Sep 17 00:00:00 2001 From: ConfusedPolarBear <33811686+ConfusedPolarBear@users.noreply.github.com> Date: Mon, 20 Jun 2022 01:07:03 -0500 Subject: [PATCH] Ignore corrupt fingerprint cache files --- .../Chromaprint.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Chromaprint.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Chromaprint.cs index dd680eb..950679a 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Chromaprint.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Chromaprint.cs @@ -188,9 +188,23 @@ public static class Chromaprint // Read each stringified uint. result.EnsureCapacity(raw.Length); - foreach (var rawNumber in raw) + + try { - result.Add(Convert.ToUInt32(rawNumber, CultureInfo.InvariantCulture)); + foreach (var rawNumber in raw) + { + result.Add(Convert.ToUInt32(rawNumber, CultureInfo.InvariantCulture)); + } + } + catch (FormatException) + { + // Occurs when the cached fingerprint is corrupt. + Logger?.LogDebug( + "Cached fingerprint for {Path} ({Id}) is corrupt, ignoring cache", + episode.Path, + episode.EpisodeId); + + return false; } fingerprint = result.AsReadOnly();