From 151a4aee59dbcf66dc926616b8edb8f08ce16ed8 Mon Sep 17 00:00:00 2001 From: Qstick Date: Tue, 10 Sep 2019 22:02:28 -0400 Subject: [PATCH] Fixed: Don't import duplicate NFO extra files Co-Authored-By: Mark McDowall --- src/NzbDrone.Core/Extras/ExtraService.cs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core/Extras/ExtraService.cs b/src/NzbDrone.Core/Extras/ExtraService.cs index ced94df47..17b2168f8 100644 --- a/src/NzbDrone.Core/Extras/ExtraService.cs +++ b/src/NzbDrone.Core/Extras/ExtraService.cs @@ -74,9 +74,28 @@ namespace NzbDrone.Core.Extras .Select(e => e.Trim(' ', '.')) .ToList(); - var matchingFilenames = files.Where(f => Path.GetFileNameWithoutExtension(f).StartsWith(sourceFileName, StringComparison.InvariantCultureIgnoreCase)); + var matchingFilenames = files.Where(f => Path.GetFileNameWithoutExtension(f).StartsWith(sourceFileName, StringComparison.InvariantCultureIgnoreCase)).ToList(); + var filteredFilenames = new List(); + var hasNfo = false; foreach (var matchingFilename in matchingFilenames) + { + // Filter out duplicate NFO files + + if (matchingFilename.EndsWith(".nfo", StringComparison.InvariantCultureIgnoreCase)) + { + if (hasNfo) + { + continue; + } + + hasNfo = true; + } + + filteredFilenames.Add(matchingFilename); + } + + foreach (var matchingFilename in filteredFilenames) { var matchingExtension = wantedExtensions.FirstOrDefault(e => matchingFilename.EndsWith(e));