diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/FreeSpaceSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/FreeSpaceSpecificationFixture.cs index 42f57fb6c..04e489e03 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/FreeSpaceSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/FreeSpaceSpecificationFixture.cs @@ -1,3 +1,4 @@ +using System.IO; using FluentAssertions; using Moq; using NUnit.Framework; @@ -90,5 +91,16 @@ public void should_return_true_if_skip_free_space_check_is_true() Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); } + + [Test] + public void should_return_true_if_root_folder_is_not_available() + { + WithMinimumFreeSpace(150); + WithSize(100); + + Mocker.GetMock().Setup(s => s.GetAvailableSpace(It.IsAny())).Throws(); + + Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue(); + } } } diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/FreeSpaceSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/FreeSpaceSpecification.cs index 1967bb1db..e35a60946 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/FreeSpaceSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/FreeSpaceSpecification.cs @@ -1,3 +1,4 @@ +using System.IO; using NLog; using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; @@ -32,11 +33,21 @@ public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCrit } var size = subject.Release.Size; - var freeSpace = _diskProvider.GetAvailableSpace(subject.Movie.Path); + var path = subject.Movie.Path; + long? freeSpace = null; + + try + { + freeSpace = _diskProvider.GetAvailableSpace(path); + } + catch (DirectoryNotFoundException) + { + // Ignore so it'll be skipped in the following checks + } if (!freeSpace.HasValue) { - _logger.Debug("Unable to get available space for {0}. Skipping", subject.Movie.Path); + _logger.Debug("Unable to get available space for {0}. Skipping", path); return Decision.Accept(); }