FreeSpaceSpec will return true is free space check returns null
This commit is contained in:
parent
89d603d71c
commit
d4096f8786
|
@ -123,14 +123,24 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
|
||||||
[Test]
|
[Test]
|
||||||
public void should_skip_check_for_files_under_series_folder()
|
public void should_skip_check_for_files_under_series_folder()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<IDiskProvider>()
|
_localEpisode.ExistingFile = true;
|
||||||
.Setup(s => s.IsParent(It.IsAny<String>(), It.IsAny<String>()))
|
|
||||||
.Returns(true);
|
|
||||||
|
|
||||||
Subject.IsSatisfiedBy(_localEpisode).Should().BeTrue();
|
Subject.IsSatisfiedBy(_localEpisode).Should().BeTrue();
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Verify(s => s.GetAvailableSpace(It.IsAny<String>()), Times.Never());
|
.Verify(s => s.GetAvailableSpace(It.IsAny<String>()), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_true_if_free_space_is_null()
|
||||||
|
{
|
||||||
|
long? freeSpace = null;
|
||||||
|
|
||||||
|
Mocker.GetMock<IDiskProvider>()
|
||||||
|
.Setup(s => s.GetAvailableSpace(It.IsAny<String>()))
|
||||||
|
.Returns(freeSpace);
|
||||||
|
|
||||||
|
Subject.IsSatisfiedBy(_localEpisode).Should().BeTrue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,9 +29,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
|
||||||
|
|
||||||
private void GivenChildOfSeries()
|
private void GivenChildOfSeries()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<IDiskProvider>()
|
_localEpisode.ExistingFile = true;
|
||||||
.Setup(s => s.IsParent(_localEpisode.Series.Path, _localEpisode.Path))
|
|
||||||
.Returns(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GivenNewFile()
|
private void GivenNewFile()
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_diskProvider.IsParent(localEpisode.Series.Path, localEpisode.Path))
|
if (localEpisode.ExistingFile)
|
||||||
{
|
{
|
||||||
_logger.Trace("Skipping free space check for existing episode");
|
_logger.Trace("Skipping free space check for existing episode");
|
||||||
return true;
|
return true;
|
||||||
|
@ -32,6 +32,12 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
||||||
var path = Directory.GetParent(localEpisode.Series.Path);
|
var path = Directory.GetParent(localEpisode.Series.Path);
|
||||||
var freeSpace = _diskProvider.GetAvailableSpace(path.FullName);
|
var freeSpace = _diskProvider.GetAvailableSpace(path.FullName);
|
||||||
|
|
||||||
|
if (!freeSpace.HasValue)
|
||||||
|
{
|
||||||
|
_logger.Trace("Free space check returned an invalid result for: {0}", path);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (freeSpace < localEpisode.Size + 100.Megabytes())
|
if (freeSpace < localEpisode.Size + 100.Megabytes())
|
||||||
{
|
{
|
||||||
_logger.Warn("Not enough free space to import: {0}", localEpisode);
|
_logger.Warn("Not enough free space to import: {0}", localEpisode);
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
||||||
|
|
||||||
public bool IsSatisfiedBy(LocalEpisode localEpisode)
|
public bool IsSatisfiedBy(LocalEpisode localEpisode)
|
||||||
{
|
{
|
||||||
if (_diskProvider.IsParent(localEpisode.Series.Path, localEpisode.Path))
|
if (localEpisode.ExistingFile)
|
||||||
{
|
{
|
||||||
_logger.Trace("{0} is in series folder, skipping in use check", localEpisode.Path);
|
_logger.Trace("{0} is in series folder, skipping in use check", localEpisode.Path);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
||||||
|
|
||||||
public bool IsSatisfiedBy(LocalEpisode localEpisode)
|
public bool IsSatisfiedBy(LocalEpisode localEpisode)
|
||||||
{
|
{
|
||||||
if (_diskProvider.IsParent(localEpisode.Series.Path, localEpisode.Path))
|
if (localEpisode.ExistingFile)
|
||||||
{
|
{
|
||||||
_logger.Trace("{0} is in series folder, unpacking check", localEpisode.Path);
|
_logger.Trace("{0} is in series folder, unpacking check", localEpisode.Path);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -7,12 +7,13 @@ namespace NzbDrone.Core.Parser.Model
|
||||||
{
|
{
|
||||||
public class LocalEpisode
|
public class LocalEpisode
|
||||||
{
|
{
|
||||||
public string Path { get; set; }
|
public String Path { get; set; }
|
||||||
public Int64 Size { get; set; }
|
public Int64 Size { get; set; }
|
||||||
public ParsedEpisodeInfo ParsedEpisodeInfo { get; set; }
|
public ParsedEpisodeInfo ParsedEpisodeInfo { get; set; }
|
||||||
public Series Series { get; set; }
|
public Series Series { get; set; }
|
||||||
public List<Episode> Episodes { get; set; }
|
public List<Episode> Episodes { get; set; }
|
||||||
public QualityModel Quality { get; set; }
|
public QualityModel Quality { get; set; }
|
||||||
|
public Boolean ExistingFile { get; set; }
|
||||||
|
|
||||||
public int SeasonNumber
|
public int SeasonNumber
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
|
||||||
|
@ -18,12 +19,17 @@ namespace NzbDrone.Core.Parser
|
||||||
{
|
{
|
||||||
private readonly IEpisodeService _episodeService;
|
private readonly IEpisodeService _episodeService;
|
||||||
private readonly ISeriesService _seriesService;
|
private readonly ISeriesService _seriesService;
|
||||||
|
private readonly IDiskProvider _diskProvider;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public ParsingService(IEpisodeService episodeService, ISeriesService seriesService, Logger logger)
|
public ParsingService(IEpisodeService episodeService,
|
||||||
|
ISeriesService seriesService,
|
||||||
|
IDiskProvider diskProvider,
|
||||||
|
Logger logger)
|
||||||
{
|
{
|
||||||
_episodeService = episodeService;
|
_episodeService = episodeService;
|
||||||
_seriesService = seriesService;
|
_seriesService = seriesService;
|
||||||
|
_diskProvider = diskProvider;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +60,8 @@ namespace NzbDrone.Core.Parser
|
||||||
Quality = parsedEpisodeInfo.Quality,
|
Quality = parsedEpisodeInfo.Quality,
|
||||||
Episodes = episodes,
|
Episodes = episodes,
|
||||||
Path = filename,
|
Path = filename,
|
||||||
ParsedEpisodeInfo = parsedEpisodeInfo
|
ParsedEpisodeInfo = parsedEpisodeInfo,
|
||||||
|
ExistingFile = _diskProvider.IsParent(series.Path, filename)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue