From 4ea35ae626ce0ac3d9554bcf51fc9f58fa57279e Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 12 Aug 2013 08:29:01 -0700 Subject: [PATCH] Free space check should use series' parent directory --- .../FreeSpaceSpecificationFixture.cs | 15 +++++++++++++++ .../Specifications/FreeSpaceSpecification.cs | 5 +++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/NzbDrone.Core.Test/MediaFileTests/EpisodeImportTests/FreeSpaceSpecificationFixture.cs b/NzbDrone.Core.Test/MediaFileTests/EpisodeImportTests/FreeSpaceSpecificationFixture.cs index bda744ca5..d58cbd6c4 100644 --- a/NzbDrone.Core.Test/MediaFileTests/EpisodeImportTests/FreeSpaceSpecificationFixture.cs +++ b/NzbDrone.Core.Test/MediaFileTests/EpisodeImportTests/FreeSpaceSpecificationFixture.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Linq; using FizzWare.NBuilder; using FluentAssertions; @@ -19,12 +20,14 @@ public class FreeSpaceSpecificationFixture : CoreTest { private Series _series; private LocalEpisode _localEpisode; + private const String ROOT_FOLDER = @"C:\Test\TV"; [SetUp] public void Setup() { _series = Builder.CreateNew() .With(s => s.SeriesType = SeriesTypes.Standard) + .With(s => s.Path = Path.Combine(ROOT_FOLDER, "30 Rock")) .Build(); var episodes = Builder.CreateListOfSize(1) @@ -81,5 +84,17 @@ public void should_accept_when_there_is_enough_disk_space() Subject.IsSatisfiedBy(_localEpisode).Should().BeTrue(); } + + [Test] + public void should_use_series_paths_parent_for_free_space_check() + { + GivenFileSize(100.Megabytes()); + GivenFreeSpace(1.Gigabytes()); + + Subject.IsSatisfiedBy(_localEpisode).Should().BeTrue(); + + Mocker.GetMock() + .Verify(v => v.GetAvilableSpace(ROOT_FOLDER), Times.Once()); + } } } diff --git a/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/FreeSpaceSpecification.cs b/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/FreeSpaceSpecification.cs index 4d017775b..b9a7bd717 100644 --- a/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/FreeSpaceSpecification.cs +++ b/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/FreeSpaceSpecification.cs @@ -21,8 +21,9 @@ public FreeSpaceSpecification(IDiskProvider diskProvider, Logger logger) public string RejectionReason { get { return "Not enough free space"; } } public bool IsSatisfiedBy(LocalEpisode localEpisode) - { - var freeSpace = _diskProvider.GetAvilableSpace(localEpisode.Series.Path); + { + var path = Directory.GetParent(localEpisode.Series.Path); + var freeSpace = _diskProvider.GetAvilableSpace(path.FullName); if (freeSpace < localEpisode.Size + 100.Megabytes()) {