Post processor now deletes folders that are less than 40MB.

pull/6/head
kay.one 13 years ago
parent 3dd7b3d768
commit b3e4485d71

@ -116,7 +116,7 @@ namespace NzbDrone.Core.Test.ProviderTests
var mocker = new AutoMoqer(MockBehavior.Strict);
parseResultSingle.Series = series30minutes;
parseResultSingle.Size = 10000.Megabytes();
parseResultSingle.Size = 1.Gigabytes();
mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
@ -137,7 +137,7 @@ namespace NzbDrone.Core.Test.ProviderTests
var mocker = new AutoMoqer(MockBehavior.Strict);
parseResultSingle.Series = series60minutes;
parseResultSingle.Size = 10000.Megabytes();
parseResultSingle.Size = 1.Gigabytes();
mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
@ -200,7 +200,7 @@ namespace NzbDrone.Core.Test.ProviderTests
var mocker = new AutoMoqer(MockBehavior.Strict);
parseResultMulti.Series = series30minutes;
parseResultMulti.Size = 10000.Megabytes();
parseResultMulti.Size = 1.Gigabytes();
mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
@ -221,7 +221,7 @@ namespace NzbDrone.Core.Test.ProviderTests
var mocker = new AutoMoqer(MockBehavior.Strict);
parseResultMulti.Series = series60minutes;
parseResultMulti.Size = 10000.Megabytes();
parseResultMulti.Size = 10.Gigabytes();
mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
@ -284,7 +284,7 @@ namespace NzbDrone.Core.Test.ProviderTests
var mocker = new AutoMoqer(MockBehavior.Strict);
parseResultSingle.Series = series30minutes;
parseResultSingle.Size = 10000.Megabytes();
parseResultSingle.Size = 1.Gigabytes();
mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
@ -305,7 +305,7 @@ namespace NzbDrone.Core.Test.ProviderTests
var mocker = new AutoMoqer(MockBehavior.Strict);
parseResultSingle.Series = series60minutes;
parseResultSingle.Size = 10000.Megabytes();
parseResultSingle.Size = 10.Gigabytes();
mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);

@ -104,7 +104,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("office")).Returns(fakeSeries);
mocker.GetMock<DiskScanProvider>().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(new List<EpisodeFile>());
mocker.GetMock<DiskProvider>().Setup(s => s.MoveDirectory(droppedFolder.FullName, taggedFolder));
mocker.GetMock<DiskProvider>().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(100.Megabytes());
mocker.GetMock<DiskProvider>().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(Constants.IgnoreFileSize + 10.Megabytes());
mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
@ -136,7 +136,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
//Act
mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("office")).Returns(fakeSeries);
mocker.GetMock<DiskProvider>().Setup(s => s.MoveDirectory(droppedFolder.FullName, taggedFolder));
mocker.GetMock<DiskProvider>().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(100.Megabytes());
mocker.GetMock<DiskProvider>().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(Constants.IgnoreFileSize + 10.Megabytes());
mocker.GetMock<DiskScanProvider>().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(fakeEpisodeFiles);
mocker.GetMock<DiskScanProvider>().Setup(s => s.MoveEpisodeFile(It.IsAny<EpisodeFile>(), true)).Returns(true);
@ -210,7 +210,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("office")).Returns(fakeSeries);
mocker.GetMock<DiskScanProvider>().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(fakeEpisodeFiles);
mocker.GetMock<DiskScanProvider>().Setup(s => s.MoveEpisodeFile(It.IsAny<EpisodeFile>(), true)).Returns(true);
mocker.GetMock<DiskProvider>().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(1.Megabytes());
mocker.GetMock<DiskProvider>().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(Constants.IgnoreFileSize - 1.Megabytes());
mocker.GetMock<DiskProvider>().Setup(s => s.DeleteFolder(droppedFolder.FullName, true));
//Act

@ -0,0 +1,15 @@
using System.Linq;
namespace NzbDrone.Core
{
public static class Constants
{
public static long IgnoreFileSize
{
get
{
return 40.Megabytes();
}
}
}
}

@ -174,6 +174,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Constants.cs" />
<Compile Include="Datastore\Connection.cs" />
<Compile Include="Datastore\MigrationLogger.cs" />
<Compile Include="Datastore\MigrationsHelper.cs" />

@ -104,7 +104,7 @@ namespace NzbDrone.Core.Providers
long size = _diskProvider.GetSize(filePath);
//If Size is less than 40MB and contains sample. Check for Size to ensure its not an episode with sample in the title
if (size < 40.Megabytes() && filePath.ToLower().Contains("sample"))
if (size < Constants.IgnoreFileSize && filePath.ToLower().Contains("sample"))
{
Logger.Trace("[{0}] appears to be a sample. skipping.", filePath);
return null;

@ -68,7 +68,7 @@ namespace NzbDrone.Core.Providers
importedFiles.ForEach(file => _diskScanProvider.MoveEpisodeFile(file, true));
//Delete the folder only if folder is small enough
if (_diskProvider.GetDirectorySize(subfolderInfo.FullName) < 10.Megabytes())
if (_diskProvider.GetDirectorySize(subfolderInfo.FullName) < Constants.IgnoreFileSize)
{
_diskProvider.DeleteFolder(subfolderInfo.FullName, true);
}

Loading…
Cancel
Save