From 1977f4aa3c55cc0a06e1958e611f366d56cc346e Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 7 Aug 2022 13:26:22 -0700 Subject: [PATCH] Fixed: Don't process files that don't have a supported media file extension --- .../MediaFiles/DownloadedEpisodesImportService.cs | 15 +++++++++++++++ .../MediaFiles/MediaFileExtensions.cs | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs b/src/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs index 931c13b6a..5368e6faf 100644 --- a/src/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs +++ b/src/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs @@ -5,6 +5,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.EpisodeImport; @@ -243,6 +244,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 LocalEpisode { Path = fileInfo.FullName }, + new Rejection($"Invalid video file, unsupported extension: '{extension}'")), + $"Invalid video file, unsupported extension: '{extension}'") + }; + } + if (downloadClientItem == null) { if (_diskProvider.IsFileLocked(fileInfo.FullName)) diff --git a/src/NzbDrone.Core/MediaFiles/MediaFileExtensions.cs b/src/NzbDrone.Core/MediaFiles/MediaFileExtensions.cs index 33fcbf607..1db0e87e6 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaFileExtensions.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaFileExtensions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using NzbDrone.Core.Qualities;