From e9b11e55e918ac3dbb77bfe77dc717200014418d Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Wed, 4 Jul 2018 21:52:26 +0200 Subject: [PATCH] Fixed: Regression with importing nested obfuscated directories. Closes #2640 --- .../Specifications/FullSeasonSpecificationFixture.cs | 7 +++++++ .../Specifications/MatchesFolderSpecificationFixture.cs | 9 +++++++++ .../Specifications/FullSeasonSpecification.cs | 5 +++++ .../Specifications/MatchesFolderSpecification.cs | 8 ++++++++ 4 files changed, 29 insertions(+) diff --git a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/FullSeasonSpecificationFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/FullSeasonSpecificationFixture.cs index e2704af6b..764eb5a77 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/FullSeasonSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/FullSeasonSpecificationFixture.cs @@ -29,6 +29,13 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications }; } + [Test] + public void should_return_true_if_no_fileinfo_available() + { + _localEpisode.FileEpisodeInfo = null; + Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeTrue(); + } + [Test] public void should_return_false_when_file_contains_the_full_season() { diff --git a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecificationFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecificationFixture.cs index dc6880cd6..cab1754dd 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecificationFixture.cs @@ -50,6 +50,15 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeTrue(); } + [Test] + public void should_be_accepted_if_file_name_is_not_parseable() + { + _localEpisode.Path = @"C:\Test\Unsorted\Series.Title.S01E01\AFDAFD.mkv".AsOsAgnostic(); + _localEpisode.FileEpisodeInfo = null; + + Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeTrue(); + } + [Test] public void should_should_be_accepted_for_full_season() { diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/FullSeasonSpecification.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/FullSeasonSpecification.cs index 37ecbbf40..64734ed01 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/FullSeasonSpecification.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/FullSeasonSpecification.cs @@ -16,6 +16,11 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications public Decision IsSatisfiedBy(LocalEpisode localEpisode, DownloadClientItem downloadClientItem) { + if (localEpisode.FileEpisodeInfo == null) + { + return Decision.Accept(); + } + if (localEpisode.FileEpisodeInfo.FullSeason) { _logger.Debug("Single episode file detected as containing all episodes in the season"); diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecification.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecification.cs index 2f69ea95c..8c85ad958 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecification.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/MatchesFolderSpecification.cs @@ -34,11 +34,19 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications if (folderInfo == null) { + _logger.Debug("No folder ParsedEpisodeInfo, skipping check"); + return Decision.Accept(); + } + + if (fileInfo == null) + { + _logger.Debug("No file ParsedEpisodeInfo, skipping check"); return Decision.Accept(); } if (!folderInfo.EpisodeNumbers.Any()) { + _logger.Debug("No episode numbers in folder ParsedEpisodeInfo, skipping check"); return Decision.Accept(); }