mirror of
https://github.com/Radarr/Radarr
synced 2024-12-26 09:49:00 +00:00
Free space check should use series' parent directory
This commit is contained in:
parent
f23c7e94ff
commit
4ea35ae626
2 changed files with 18 additions and 2 deletions
|
@ -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<FreeSpaceSpecification>
|
|||
{
|
||||
private Series _series;
|
||||
private LocalEpisode _localEpisode;
|
||||
private const String ROOT_FOLDER = @"C:\Test\TV";
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_series = Builder<Series>.CreateNew()
|
||||
.With(s => s.SeriesType = SeriesTypes.Standard)
|
||||
.With(s => s.Path = Path.Combine(ROOT_FOLDER, "30 Rock"))
|
||||
.Build();
|
||||
|
||||
var episodes = Builder<Episode>.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<IDiskProvider>()
|
||||
.Verify(v => v.GetAvilableSpace(ROOT_FOLDER), Times.Once());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,8 @@ public FreeSpaceSpecification(IDiskProvider diskProvider, Logger logger)
|
|||
|
||||
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())
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue