From 0fbb45c1753b77b1cca6ad88cab72c18c1bc09c1 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 15 Jul 2013 23:43:45 -0700 Subject: [PATCH] Moved SampleSizeLimit to Spec --- NzbDrone.Core/Constants.cs | 13 ------------- .../MediaFiles/DownloadedEpisodesImportService.cs | 4 +++- .../Specifications/NotSampleSpecification.cs | 15 +++++++++++---- NzbDrone.Core/NzbDrone.Core.csproj | 1 - 4 files changed, 14 insertions(+), 19 deletions(-) delete mode 100644 NzbDrone.Core/Constants.cs diff --git a/NzbDrone.Core/Constants.cs b/NzbDrone.Core/Constants.cs deleted file mode 100644 index 883525059..000000000 --- a/NzbDrone.Core/Constants.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace NzbDrone.Core -{ - public static class Constants - { - public static long IgnoreFileSize - { - get - { - return 70.Megabytes(); - } - } - } -} diff --git a/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs b/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs index 9a9d25e03..f91beaf08 100644 --- a/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs +++ b/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs @@ -7,6 +7,7 @@ using NzbDrone.Core.Configuration; using NzbDrone.Core.MediaFiles.Commands; using NzbDrone.Core.MediaFiles.EpisodeImport; +using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications; using NzbDrone.Core.Parser; using NzbDrone.Core.Tv; @@ -64,7 +65,8 @@ public void ProcessDownloadedEpisodesFolder() { ProcessSubFolder(new DirectoryInfo(subfolder)); - if (_diskProvider.GetFolderSize(subfolder) < 50.Megabytes()) + //Todo: We should make sure the file(s) are actually imported + if (_diskProvider.GetFolderSize(subfolder) < NotSampleSpecification.SampleSizeLimit) { _diskProvider.DeleteFolder(subfolder, true); } diff --git a/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotSampleSpecification.cs b/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotSampleSpecification.cs index 6c8b8c152..c5ca01b08 100644 --- a/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotSampleSpecification.cs +++ b/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotSampleSpecification.cs @@ -12,17 +12,24 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications { public class NotSampleSpecification : IImportDecisionEngineSpecification { - private readonly IDiskProvider _diskProvider; private readonly IVideoFileInfoReader _videoFileInfoReader; private readonly Logger _logger; - public NotSampleSpecification(IDiskProvider diskProvider, IVideoFileInfoReader videoFileInfoReader, Logger logger) + public NotSampleSpecification(IVideoFileInfoReader videoFileInfoReader, + Logger logger) { - _diskProvider = diskProvider; _videoFileInfoReader = videoFileInfoReader; _logger = logger; } + public static long SampleSizeLimit + { + get + { + return 70.Megabytes(); + } + } + public string RejectionReason { get { return "Sample"; } } public bool IsSatisfiedBy(LocalEpisode localEpisode) @@ -41,7 +48,7 @@ public bool IsSatisfiedBy(LocalEpisode localEpisode) var runTime = _videoFileInfoReader.GetRunTime(localEpisode.Path); - if (localEpisode.Size < Constants.IgnoreFileSize && runTime.TotalMinutes < 3) + if (localEpisode.Size < SampleSizeLimit && runTime.TotalMinutes < 3) { _logger.Trace("[{0}] appears to be a sample.", localEpisode.Path); return false; diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 990cee3a1..70600f2d9 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -184,7 +184,6 @@ -