From d27d982120f08c51972bea1009ce7a1d97e0b203 Mon Sep 17 00:00:00 2001 From: "servarr[bot]" <68984020+servarr[bot]@users.noreply.github.com> Date: Sat, 20 Aug 2022 00:01:15 -0500 Subject: [PATCH] Fixed: Don't process files that don't have a supported media file extension (#2938) * Fixed: Don't process files that don't have a supported media file extension (cherry picked from commit 1977f4aa3c55cc0a06e1958e611f366d56cc346e) * fixup! * fixup! Co-authored-by: Mark McDowall Co-authored-by: Qstick --- .../MediaFiles/DownloadedTracksImportService.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/NzbDrone.Core/MediaFiles/DownloadedTracksImportService.cs b/src/NzbDrone.Core/MediaFiles/DownloadedTracksImportService.cs index 32c00b908..d26cf0525 100644 --- a/src/NzbDrone.Core/MediaFiles/DownloadedTracksImportService.cs +++ b/src/NzbDrone.Core/MediaFiles/DownloadedTracksImportService.cs @@ -6,6 +6,7 @@ using System.Linq; using NLog; using NzbDrone.Common.Disk; using NzbDrone.Common.EnvironmentInfo; +using NzbDrone.Common.Extensions; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.MediaFiles.Events; @@ -276,6 +277,20 @@ namespace NzbDrone.Core.MediaFiles }; } + var extension = Path.GetExtension(fileInfo.Name); + + if (extension.IsNullOrWhiteSpace() || !MediaFileExtensions.Extensions.Contains(extension)) + { + _logger.Debug("[{0}] has an unsupported extension: '{1}'", fileInfo.FullName, extension); + + return new List + { + new ImportResult(new ImportDecision(new LocalTrack { Path = fileInfo.FullName }, + new Rejection($"Invalid audio file, unsupported extension: '{extension}'")), + $"Invalid audio file, unsupported extension: '{extension}'") + }; + } + if (downloadClientItem == null) { if (_diskProvider.IsFileLocked(fileInfo.FullName))