1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-09 04:22:30 +01:00

Fixed: Sample files of daily episodes should also be deleted after import.

This commit is contained in:
Taloth Saldono 2016-02-10 23:46:50 +01:00
parent 1c92ea58da
commit 91d91bc673
8 changed files with 23 additions and 16 deletions

View File

@ -167,7 +167,7 @@ public void should_delete_folder_if_files_were_imported_and_only_sample_files_re
It.IsAny<QualityModel>(),
It.IsAny<string>(),
It.IsAny<long>(),
It.IsAny<int>()))
It.IsAny<bool>()))
.Returns(true);
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
@ -239,7 +239,7 @@ public void should_not_delete_if_there_is_large_rar_file()
It.IsAny<QualityModel>(),
It.IsAny<string>(),
It.IsAny<long>(),
It.IsAny<int>()))
It.IsAny<bool>()))
.Returns(true);
Mocker.GetMock<IDiskProvider>()
@ -350,7 +350,7 @@ public void should_not_delete_if_no_files_were_imported()
It.IsAny<QualityModel>(),
It.IsAny<string>(),
It.IsAny<long>(),
It.IsAny<int>()))
It.IsAny<bool>()))
.Returns(true);
Mocker.GetMock<IDiskProvider>()

View File

@ -332,7 +332,7 @@ public void should_use_folder_when_only_one_video_file_and_a_sample()
GivenVideoFiles(videoFiles.ToList());
Mocker.GetMock<IDetectSample>()
.Setup(s => s.IsSample(_series, It.IsAny<QualityModel>(), It.Is<string>(c => c.Contains("sample")), It.IsAny<long>(), It.IsAny<int>()))
.Setup(s => s.IsSample(_series, It.IsAny<QualityModel>(), It.Is<string>(c => c.Contains("sample")), It.IsAny<long>(), It.IsAny<bool>()))
.Returns(true);
var folderInfo = Parser.Parser.ParseTitle("Series.Title.S01E01");

View File

@ -91,7 +91,7 @@ public void should_use_runtime()
_localEpisode.Quality,
_localEpisode.Path,
_localEpisode.Size,
_localEpisode.SeasonNumber);
_localEpisode.IsSpecial);
Mocker.GetMock<IVideoFileInfoReader>().Verify(v => v.GetRunTime(It.IsAny<string>()), Times.Once());
}
@ -144,7 +144,7 @@ public void should_not_treat_daily_episode_a_special()
}
[Test]
public void should_return_false_for_anime_speical()
public void should_return_false_for_anime_special()
{
_series.SeriesType = SeriesTypes.Anime;
_localEpisode.Episodes[0].SeasonNumber = 0;
@ -158,7 +158,7 @@ private void ShouldBeTrue()
_localEpisode.Quality,
_localEpisode.Path,
_localEpisode.Size,
_localEpisode.SeasonNumber).Should().BeTrue();
_localEpisode.IsSpecial).Should().BeTrue();
}
private void ShouldBeFalse()
@ -167,7 +167,7 @@ private void ShouldBeFalse()
_localEpisode.Quality,
_localEpisode.Path,
_localEpisode.Size,
_localEpisode.SeasonNumber).Should().BeFalse();
_localEpisode.IsSpecial).Should().BeFalse();
}
}
}

View File

@ -117,8 +117,7 @@ public bool ShouldDeleteFolder(DirectoryInfo directoryInfo, Series series)
var size = _diskProvider.GetFileSize(videoFile);
var quality = QualityParser.ParseQuality(videoFile);
if (!_detectSample.IsSample(series, quality, videoFile, size,
episodeParseResult.SeasonNumber))
if (!_detectSample.IsSample(series, quality, videoFile, size, episodeParseResult.IsPossibleSpecialEpisode))
{
_logger.Warn("Non-sample file detected: [{0}]", videoFile);
return false;

View File

@ -10,7 +10,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
{
public interface IDetectSample
{
bool IsSample(Series series, QualityModel quality, string path, long size, int seasonNumber);
bool IsSample(Series series, QualityModel quality, string path, long size, bool isSpecial);
}
public class DetectSample : IDetectSample
@ -34,9 +34,9 @@ public static long SampleSizeLimit
}
}
public bool IsSample(Series series, QualityModel quality, string path, long size, int seasonNumber)
public bool IsSample(Series series, QualityModel quality, string path, long size, bool isSpecial)
{
if (seasonNumber == 0)
if (isSpecial)
{
_logger.Debug("Special, skipping sample check");
return false;

View File

@ -163,7 +163,7 @@ private bool ShouldUseFolderName(List<string> videoFiles, Series series, ParsedE
{
var size = _diskProvider.GetFileSize(file);
var fileQuality = QualityParser.ParseQuality(file);
var sample = _detectSample.IsSample(series, GetQuality(folderInfo, fileQuality, series), file, size, folderInfo.SeasonNumber);
var sample = _detectSample.IsSample(series, GetQuality(folderInfo, fileQuality, series), file, size, folderInfo.IsPossibleSpecialEpisode);
if (sample)
{

View File

@ -28,7 +28,7 @@ public Decision IsSatisfiedBy(LocalEpisode localEpisode)
localEpisode.Quality,
localEpisode.Path,
localEpisode.Size,
localEpisode.SeasonNumber);
localEpisode.IsSpecial);
if (sample)
{

View File

@ -31,6 +31,14 @@ public int SeasonNumber
}
}
public bool IsSpecial
{
get
{
return SeasonNumber == 0;
}
}
public override string ToString()
{
return Path;