From 354ed9657259d8cb7fa914a4a9e26368d97766a7 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 4 Oct 2024 20:07:22 -0700 Subject: [PATCH] Fixed: Ignore free space check before grabbing if directory is missing Closes #7273 --- .../FreeSpaceSpecificationFixture.cs | 12 ++++++++++++ .../Specifications/FreeSpaceSpecification.cs | 15 +++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/FreeSpaceSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/FreeSpaceSpecificationFixture.cs index b691c7544..957a323f3 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 @@ namespace NzbDrone.Core.Test.DecisionEngineTests Subject.IsSatisfiedBy(_remoteEpisode, 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(_remoteEpisode, null).Accepted.Should().BeTrue(); + } } } diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/FreeSpaceSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/FreeSpaceSpecification.cs index c01c94601..2d3d3b082 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 @@ namespace NzbDrone.Core.DecisionEngine.Specifications } var size = subject.Release.Size; - var freeSpace = _diskProvider.GetAvailableSpace(subject.Series.Path); + var path = subject.Series.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.Series.Path); + _logger.Debug("Unable to get available space for {0}. Skipping", path); return Decision.Accept(); }