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

pull/923/merge
Taloth Saldono 9 years ago
parent 1c92ea58da
commit 91d91bc673

@ -167,7 +167,7 @@ namespace NzbDrone.Core.Test.MediaFiles
It.IsAny<QualityModel>(), It.IsAny<QualityModel>(),
It.IsAny<string>(), It.IsAny<string>(),
It.IsAny<long>(), It.IsAny<long>(),
It.IsAny<int>())) It.IsAny<bool>()))
.Returns(true); .Returns(true);
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory)); Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
@ -239,7 +239,7 @@ namespace NzbDrone.Core.Test.MediaFiles
It.IsAny<QualityModel>(), It.IsAny<QualityModel>(),
It.IsAny<string>(), It.IsAny<string>(),
It.IsAny<long>(), It.IsAny<long>(),
It.IsAny<int>())) It.IsAny<bool>()))
.Returns(true); .Returns(true);
Mocker.GetMock<IDiskProvider>() Mocker.GetMock<IDiskProvider>()
@ -350,7 +350,7 @@ namespace NzbDrone.Core.Test.MediaFiles
It.IsAny<QualityModel>(), It.IsAny<QualityModel>(),
It.IsAny<string>(), It.IsAny<string>(),
It.IsAny<long>(), It.IsAny<long>(),
It.IsAny<int>())) It.IsAny<bool>()))
.Returns(true); .Returns(true);
Mocker.GetMock<IDiskProvider>() Mocker.GetMock<IDiskProvider>()

@ -332,7 +332,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
GivenVideoFiles(videoFiles.ToList()); GivenVideoFiles(videoFiles.ToList());
Mocker.GetMock<IDetectSample>() 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); .Returns(true);
var folderInfo = Parser.Parser.ParseTitle("Series.Title.S01E01"); var folderInfo = Parser.Parser.ParseTitle("Series.Title.S01E01");

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

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

@ -10,7 +10,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
{ {
public interface IDetectSample 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 public class DetectSample : IDetectSample
@ -34,9 +34,9 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
} }
} }
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"); _logger.Debug("Special, skipping sample check");
return false; return false;

@ -163,7 +163,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
{ {
var size = _diskProvider.GetFileSize(file); var size = _diskProvider.GetFileSize(file);
var fileQuality = QualityParser.ParseQuality(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) if (sample)
{ {

@ -28,7 +28,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
localEpisode.Quality, localEpisode.Quality,
localEpisode.Path, localEpisode.Path,
localEpisode.Size, localEpisode.Size,
localEpisode.SeasonNumber); localEpisode.IsSpecial);
if (sample) if (sample)
{ {

@ -31,6 +31,14 @@ namespace NzbDrone.Core.Parser.Model
} }
} }
public bool IsSpecial
{
get
{
return SeasonNumber == 0;
}
}
public override string ToString() public override string ToString()
{ {
return Path; return Path;

Loading…
Cancel
Save