From 89d603d71cc25996968d7c01c114ba59541e2eb1 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 13 Sep 2013 11:41:21 -0700 Subject: [PATCH] Skipping free space check when importing existing episodes --- .../FreeSpaceSpecificationFixture.cs | 20 +++++++++++++++---- .../Specifications/FreeSpaceSpecification.cs | 6 ++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/FreeSpaceSpecificationFixture.cs b/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/FreeSpaceSpecificationFixture.cs index 614b9e761..80f9ec530 100644 --- a/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/FreeSpaceSpecificationFixture.cs +++ b/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/FreeSpaceSpecificationFixture.cs @@ -39,7 +39,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications _localEpisode = new LocalEpisode { - Path = @"C:\Test\30 Rock\30.rock.s01e01.avi", + Path = @"C:\Test\Unsorted\30 Rock\30.rock.s01e01.avi".AsOsAgnostic(), Episodes = episodes, Series = _series }; @@ -98,7 +98,6 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications .Verify(v => v.GetAvailableSpace(_rootFolder), Times.Once()); } - [Test] public void should_pass_if_free_space_is_null() { @@ -114,11 +113,24 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications GivenFileSize(100.Megabytes()); Mocker.GetMock() - .Setup(s => s.GetAvailableSpace(It.IsAny())) - .Throws(new TestException()); + .Setup(s => s.GetAvailableSpace(It.IsAny())) + .Throws(new TestException()); Subject.IsSatisfiedBy(_localEpisode).Should().BeTrue(); ExceptionVerification.ExpectedErrors(1); } + + [Test] + public void should_skip_check_for_files_under_series_folder() + { + Mocker.GetMock() + .Setup(s => s.IsParent(It.IsAny(), It.IsAny())) + .Returns(true); + + Subject.IsSatisfiedBy(_localEpisode).Should().BeTrue(); + + Mocker.GetMock() + .Verify(s => s.GetAvailableSpace(It.IsAny()), Times.Never()); + } } } diff --git a/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/FreeSpaceSpecification.cs b/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/FreeSpaceSpecification.cs index 2d21b7500..0bdfd812b 100644 --- a/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/FreeSpaceSpecification.cs +++ b/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/FreeSpaceSpecification.cs @@ -23,6 +23,12 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications { try { + if (_diskProvider.IsParent(localEpisode.Series.Path, localEpisode.Path)) + { + _logger.Trace("Skipping free space check for existing episode"); + return true; + } + var path = Directory.GetParent(localEpisode.Series.Path); var freeSpace = _diskProvider.GetAvailableSpace(path.FullName);