Ensure drone factory runs on its specificed interval (#1067)

* Ensure drone factory runs on its specificed interval
* Fix the tests for DownloadedMovieImportServiceFixture
pull/2/head
Tim Turner 8 years ago committed by GitHub
parent fe0a54685f
commit 5c22d0b61d

@ -12,13 +12,13 @@ namespace NzbDrone.Api.Config
MappedNetworkDriveValidator mappedNetworkDriveValidator)
: base(configService)
{
SharedValidator.RuleFor(c => c.DownloadedEpisodesFolder)
SharedValidator.RuleFor(c => c.DownloadedMoviesFolder)
.Cascade(CascadeMode.StopOnFirstFailure)
.IsValidPath()
.SetValidator(rootFolderValidator)
.SetValidator(mappedNetworkDriveValidator)
.SetValidator(pathExistsValidator)
.When(c => !string.IsNullOrWhiteSpace(c.DownloadedEpisodesFolder));
.When(c => !string.IsNullOrWhiteSpace(c.DownloadedMoviesFolder));
}
protected override DownloadClientConfigResource ToResource(IConfigService model)

@ -5,9 +5,9 @@ namespace NzbDrone.Api.Config
{
public class DownloadClientConfigResource : RestResource
{
public string DownloadedEpisodesFolder { get; set; }
public string DownloadedMoviesFolder { get; set; }
public string DownloadClientWorkingFolders { get; set; }
public int DownloadedEpisodesScanInterval { get; set; }
public int DownloadedMoviesScanInterval { get; set; }
public bool EnableCompletedDownloadHandling { get; set; }
public bool RemoveCompletedDownloads { get; set; }
@ -22,9 +22,9 @@ namespace NzbDrone.Api.Config
{
return new DownloadClientConfigResource
{
DownloadedEpisodesFolder = model.DownloadedEpisodesFolder,
DownloadedMoviesFolder = model.DownloadedMoviesFolder,
DownloadClientWorkingFolders = model.DownloadClientWorkingFolders,
DownloadedEpisodesScanInterval = model.DownloadedEpisodesScanInterval,
DownloadedMoviesScanInterval = model.DownloadedMoviesScanInterval,
EnableCompletedDownloadHandling = model.EnableCompletedDownloadHandling,
RemoveCompletedDownloads = model.RemoveCompletedDownloads,

@ -154,7 +154,7 @@ namespace NzbDrone.Core.Test.Download
public void should_not_process_if_storage_directory_in_drone_factory()
{
Mocker.GetMock<IConfigService>()
.SetupGet(v => v.DownloadedEpisodesFolder)
.SetupGet(v => v.DownloadedMoviesFolder)
.Returns(@"C:\DropFolder".AsOsAgnostic());
_trackedDownload.DownloadItem.OutputPath = new OsPath(@"C:\DropFolder\SomeOtherFolder".AsOsAgnostic());
@ -372,8 +372,8 @@ namespace NzbDrone.Core.Test.Download
private void AssertNoAttemptedImport()
{
Mocker.GetMock<IDownloadedEpisodesImportService>()
.Verify(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()), Times.Never());
Mocker.GetMock<IDownloadedMovieImportService>()
.Verify(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Movie>(), It.IsAny<DownloadClientItem>()), Times.Never());
AssertNoCompletedDownload();
}

@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using System.Net;
using Moq;
@ -31,7 +31,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
_nzbPath = Path.Combine(_pneumaticFolder, _title + ".nzb").AsOsAgnostic();
_sabDrop = @"d:\unsorted tv\".AsOsAgnostic();
Mocker.GetMock<IConfigService>().SetupGet(c => c.DownloadedEpisodesFolder).Returns(_sabDrop);
Mocker.GetMock<IConfigService>().SetupGet(c => c.DownloadedMoviesFolder).Returns(_sabDrop);
_remoteMovie = new RemoteMovie();
_remoteMovie.Release = new ReleaseInfo();

@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
private void GivenDroneFactoryFolder(bool exists = false, bool writable = true)
{
Mocker.GetMock<IConfigService>()
.SetupGet(s => s.DownloadedEpisodesFolder)
.SetupGet(s => s.DownloadedMoviesFolder)
.Returns(DRONE_FACTORY_FOLDER);
Mocker.GetMock<IDiskProvider>()

@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
private void GivenDroneFactoryFolder(bool exists = false)
{
Mocker.GetMock<IConfigService>()
.SetupGet(s => s.DownloadedEpisodesFolder)
.SetupGet(s => s.DownloadedMoviesFolder)
.Returns(DRONE_FACTORY_FOLDER.AsOsAgnostic());
Mocker.GetMock<IDiskProvider>()

@ -0,0 +1,172 @@
using System.Collections.Generic;
using System.IO;
using FizzWare.NBuilder;
using Moq;
using NUnit.Framework;
using NzbDrone.Common.Disk;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.TrackedDownloads;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MediaFiles.Commands;
using NzbDrone.Core.MediaFiles.EpisodeImport;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.MediaFiles
{
[TestFixture]
public class DownloadedMoviesCommandServiceFixture : CoreTest<DownloadedMovieCommandService>
{
private string _droneFactory = "c:\\drop\\".AsOsAgnostic();
private string _downloadFolder = "c:\\drop_other\\Show.S01E01\\".AsOsAgnostic();
private string _downloadFile = "c:\\drop_other\\Show.S01E01.mkv".AsOsAgnostic();
private TrackedDownload _trackedDownload;
[SetUp]
public void Setup()
{
Mocker.GetMock<IConfigService>().SetupGet(c => c.DownloadedMoviesFolder)
.Returns(_droneFactory);
Mocker.GetMock<IDownloadedMovieImportService>()
.Setup(v => v.ProcessRootFolder(It.IsAny<DirectoryInfo>()))
.Returns(new List<ImportResult>());
Mocker.GetMock<IDownloadedMovieImportService>()
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Movie>(), It.IsAny<DownloadClientItem>()))
.Returns(new List<ImportResult>());
var downloadItem = Builder<DownloadClientItem>.CreateNew()
.With(v => v.DownloadId = "sab1")
.With(v => v.Status = DownloadItemStatus.Downloading)
.Build();
var remoteMovie = Builder<RemoteMovie>.CreateNew()
.With(v => v.Movie = new Movie())
.Build();
_trackedDownload = new TrackedDownload
{
DownloadItem = downloadItem,
RemoteMovie = remoteMovie,
State = TrackedDownloadStage.Downloading
};
}
private void GivenExistingFolder(string path)
{
Mocker.GetMock<IDiskProvider>().Setup(c => c.FolderExists(It.IsAny<string>()))
.Returns(true);
}
private void GivenExistingFile(string path)
{
Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(It.IsAny<string>()))
.Returns(true);
}
private void GivenValidQueueItem()
{
Mocker.GetMock<ITrackedDownloadService>()
.Setup(s => s.Find("sab1"))
.Returns(_trackedDownload);
}
[Test]
public void should_process_dronefactory_if_path_is_not_specified()
{
GivenExistingFolder(_droneFactory);
Subject.Execute(new DownloadedMoviesScanCommand());
Mocker.GetMock<IDownloadedMovieImportService>().Verify(c => c.ProcessRootFolder(It.IsAny<DirectoryInfo>()), Times.Once());
}
[Test]
public void should_skip_import_if_dronefactory_doesnt_exist()
{
Subject.Execute(new DownloadedMoviesScanCommand());
Mocker.GetMock<IDownloadedMovieImportService>().Verify(c => c.ProcessRootFolder(It.IsAny<DirectoryInfo>()), Times.Never());
ExceptionVerification.ExpectedWarns(1);
}
[Test]
public void should_ignore_downloadclientid_if_path_is_not_specified()
{
GivenExistingFolder(_droneFactory);
Subject.Execute(new DownloadedMoviesScanCommand() { DownloadClientId = "sab1" });
Mocker.GetMock<IDownloadedMovieImportService>().Verify(c => c.ProcessRootFolder(It.IsAny<DirectoryInfo>()), Times.Once());
}
[Test]
public void should_process_folder_if_downloadclientid_is_not_specified()
{
GivenExistingFolder(_downloadFolder);
Subject.Execute(new DownloadedMoviesScanCommand() { Path = _downloadFolder });
Mocker.GetMock<IDownloadedMovieImportService>().Verify(c => c.ProcessPath(It.IsAny<string>(), ImportMode.Auto, null, null), Times.Once());
}
[Test]
public void should_process_file_if_downloadclientid_is_not_specified()
{
GivenExistingFile(_downloadFile);
Subject.Execute(new DownloadedMoviesScanCommand() { Path = _downloadFile });
Mocker.GetMock<IDownloadedMovieImportService>().Verify(c => c.ProcessPath(It.IsAny<string>(), ImportMode.Auto, null, null), Times.Once());
}
[Test]
public void should_process_folder_with_downloadclientitem_if_available()
{
GivenExistingFolder(_downloadFolder);
GivenValidQueueItem();
Subject.Execute(new DownloadedMoviesScanCommand() { Path = _downloadFolder, DownloadClientId = "sab1" });
Mocker.GetMock<IDownloadedMovieImportService>().Verify(c => c.ProcessPath(_downloadFolder, ImportMode.Auto, _trackedDownload.RemoteMovie.Movie, _trackedDownload.DownloadItem), Times.Once());
}
[Test]
public void should_process_folder_without_downloadclientitem_if_not_available()
{
GivenExistingFolder(_downloadFolder);
Subject.Execute(new DownloadedMoviesScanCommand() { Path = _downloadFolder, DownloadClientId = "sab1" });
Mocker.GetMock<IDownloadedMovieImportService>().Verify(c => c.ProcessPath(_downloadFolder, ImportMode.Auto, null, null), Times.Once());
ExceptionVerification.ExpectedWarns(1);
}
[Test]
public void should_warn_if_neither_folder_or_file_exists()
{
Subject.Execute(new DownloadedMoviesScanCommand() { Path = _downloadFolder });
Mocker.GetMock<IDownloadedMovieImportService>().Verify(c => c.ProcessPath(It.IsAny<string>(), ImportMode.Auto, null, null), Times.Never());
ExceptionVerification.ExpectedWarns(1);
}
[Test]
public void should_override_import_mode()
{
GivenExistingFile(_downloadFile);
Subject.Execute(new DownloadedMoviesScanCommand() { Path = _downloadFile, ImportMode = ImportMode.Copy });
Mocker.GetMock<IDownloadedMovieImportService>().Verify(c => c.ProcessPath(It.IsAny<string>(), ImportMode.Copy, null, null), Times.Once());
}
}
}

@ -0,0 +1,377 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using FizzWare.NBuilder;
using Moq;
using NUnit.Framework;
using NzbDrone.Common.Disk;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MediaFiles.EpisodeImport;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Test.Common;
using FluentAssertions;
namespace NzbDrone.Core.Test.MediaFiles
{
[TestFixture]
public class DownloadedMoviesImportServiceFixture : CoreTest<DownloadedMovieImportService>
{
private string _droneFactory = "c:\\drop\\".AsOsAgnostic();
private string[] _subFolders = new[] { "c:\\root\\foldername".AsOsAgnostic() };
private string[] _videoFiles = new[] { "c:\\root\\foldername\\47.ronin.2013.ext".AsOsAgnostic() };
[SetUp]
public void Setup()
{
Mocker.GetMock<IDiskScanService>().Setup(c => c.GetVideoFiles(It.IsAny<string>(), It.IsAny<bool>()))
.Returns(_videoFiles);
Mocker.GetMock<IDiskProvider>().Setup(c => c.GetDirectories(It.IsAny<string>()))
.Returns(_subFolders);
Mocker.GetMock<IDiskProvider>().Setup(c => c.FolderExists(It.IsAny<string>()))
.Returns(true);
Mocker.GetMock<IImportApprovedMovie>()
.Setup(s => s.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto))
.Returns(new List<ImportResult>());
}
private void GivenValidMovie()
{
Mocker.GetMock<IParsingService>()
.Setup(s => s.GetMovie(It.IsAny<string>()))
.Returns(Builder<Movie>.CreateNew().Build());
}
[Test]
public void should_search_for_series_using_folder_name()
{
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
Mocker.GetMock<IParsingService>().Verify(c => c.GetMovie("foldername"), Times.Once());
}
[Test]
public void should_skip_if_file_is_in_use_by_another_process()
{
GivenValidMovie();
Mocker.GetMock<IDiskProvider>().Setup(c => c.IsFileLocked(It.IsAny<string>()))
.Returns(true);
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
VerifyNoImport();
}
[Test]
public void should_skip_if_no_series_found()
{
Mocker.GetMock<IParsingService>().Setup(c => c.GetMovie("foldername")).Returns((Movie)null);
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
Mocker.GetMock<IMakeImportDecision>()
.Verify(c => c.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), It.IsAny<ParsedMovieInfo>(), It.IsAny<bool>()),
Times.Never());
VerifyNoImport();
}
[Test]
public void should_not_import_if_folder_is_a_series_path()
{
GivenValidMovie();
Mocker.GetMock<IMovieService>()
.Setup(s => s.MoviePathExists(It.IsAny<string>()))
.Returns(true);
Mocker.GetMock<IDiskScanService>()
.Setup(c => c.GetVideoFiles(It.IsAny<string>(), It.IsAny<bool>()))
.Returns(new string[0]);
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
Mocker.GetMock<IDiskScanService>()
.Verify(v => v.GetVideoFiles(It.IsAny<string>(), true), Times.Never());
ExceptionVerification.ExpectedWarns(1);
}
[Test]
public void should_not_delete_folder_if_no_files_were_imported()
{
Mocker.GetMock<IImportApprovedMovie>()
.Setup(s => s.Import(It.IsAny<List<ImportDecision>>(), false, null, ImportMode.Auto))
.Returns(new List<ImportResult>());
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
Mocker.GetMock<IDiskProvider>()
.Verify(v => v.GetFolderSize(It.IsAny<string>()), Times.Never());
}
[Test]
public void should_not_delete_folder_if_files_were_imported_and_video_files_remain()
{
GivenValidMovie();
var localMovie = new LocalMovie();
var imported = new List<ImportDecision>();
imported.Add(new ImportDecision(localMovie));
Mocker.GetMock<IMakeImportDecision>()
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), null, true))
.Returns(imported);
Mocker.GetMock<IImportApprovedMovie>()
.Setup(s => s.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto))
.Returns(imported.Select(i => new ImportResult(i)).ToList());
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
Mocker.GetMock<IDiskProvider>()
.Verify(v => v.DeleteFolder(It.IsAny<string>(), true), Times.Never());
ExceptionVerification.ExpectedWarns(1);
}
[Test]
public void should_delete_folder_if_files_were_imported_and_only_sample_files_remain()
{
GivenValidMovie();
var localMovie = new LocalMovie();
var imported = new List<ImportDecision>();
imported.Add(new ImportDecision(localMovie));
Mocker.GetMock<IMakeImportDecision>()
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), null, true))
.Returns(imported);
Mocker.GetMock<IImportApprovedMovie>()
.Setup(s => s.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto))
.Returns(imported.Select(i => new ImportResult(i)).ToList());
Mocker.GetMock<IDetectSample>()
.Setup(s => s.IsSample(It.IsAny<Movie>(),
It.IsAny<QualityModel>(),
It.IsAny<string>(),
It.IsAny<long>(),
It.IsAny<bool>()))
.Returns(true);
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
Mocker.GetMock<IDiskProvider>()
.Verify(v => v.DeleteFolder(It.IsAny<string>(), true), Times.Once());
}
[TestCase("_UNPACK_")]
[TestCase("_FAILED_")]
public void should_remove_unpack_from_folder_name(string prefix)
{
var folderName = "47.ronin.2013.hdtv-lol";
var folders = new[] { string.Format(@"C:\Test\Unsorted\{0}{1}", prefix, folderName).AsOsAgnostic() };
Mocker.GetMock<IDiskProvider>()
.Setup(c => c.GetDirectories(It.IsAny<string>()))
.Returns(folders);
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
Mocker.GetMock<IParsingService>()
.Verify(v => v.GetMovie(folderName), Times.Once());
Mocker.GetMock<IParsingService>()
.Verify(v => v.GetMovie(It.Is<string>(s => s.StartsWith(prefix))), Times.Never());
}
[Test]
public void should_return_importresult_on_unknown_movie()
{
Mocker.GetMock<IDiskProvider>().Setup(c => c.FolderExists(It.IsAny<string>()))
.Returns(false);
Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(It.IsAny<string>()))
.Returns(true);
var fileName = @"C:\folder\file.mkv".AsOsAgnostic();
var result = Subject.ProcessPath(fileName);
result.Should().HaveCount(1);
result.First().ImportDecision.Should().NotBeNull();
result.First().ImportDecision.LocalMovie.Should().NotBeNull();
result.First().ImportDecision.LocalMovie.Path.Should().Be(fileName);
result.First().Result.Should().Be(ImportResultType.Rejected);
}
[Test]
public void should_not_delete_if_there_is_large_rar_file()
{
GivenValidMovie();
var localMovie = new LocalMovie();
var imported = new List<ImportDecision>();
imported.Add(new ImportDecision(localMovie));
Mocker.GetMock<IMakeImportDecision>()
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), null, true))
.Returns(imported);
Mocker.GetMock<IImportApprovedMovie>()
.Setup(s => s.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto))
.Returns(imported.Select(i => new ImportResult(i)).ToList());
Mocker.GetMock<IDetectSample>()
.Setup(s => s.IsSample(It.IsAny<Movie>(),
It.IsAny<QualityModel>(),
It.IsAny<string>(),
It.IsAny<long>(),
It.IsAny<bool>()))
.Returns(true);
Mocker.GetMock<IDiskProvider>()
.Setup(s => s.GetFiles(It.IsAny<string>(), SearchOption.AllDirectories))
.Returns(new[] { _videoFiles.First().Replace(".ext", ".rar") });
Mocker.GetMock<IDiskProvider>()
.Setup(s => s.GetFileSize(It.IsAny<string>()))
.Returns(15.Megabytes());
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
Mocker.GetMock<IDiskProvider>()
.Verify(v => v.DeleteFolder(It.IsAny<string>(), true), Times.Never());
ExceptionVerification.ExpectedWarns(1);
}
[Test]
public void should_use_folder_if_folder_import()
{
GivenValidMovie();
var folderName = @"C:\media\ba09030e-1234-1234-1234-123456789abc\[HorribleSubs] American Psycho (2000) [720p]".AsOsAgnostic();
var fileName = @"C:\media\ba09030e-1234-1234-1234-123456789abc\[HorribleSubs] American Psycho (2000) [720p]\[HorribleSubs] American Psycho (2000) [720p].mkv".AsOsAgnostic();
Mocker.GetMock<IDiskProvider>().Setup(c => c.FolderExists(folderName))
.Returns(true);
Mocker.GetMock<IDiskProvider>().Setup(c => c.GetFiles(folderName, SearchOption.TopDirectoryOnly))
.Returns(new[] { fileName });
var localMovie = new LocalMovie();
var imported = new List<ImportDecision>();
imported.Add(new ImportDecision(localMovie));
Subject.ProcessPath(fileName);
Mocker.GetMock<IMakeImportDecision>()
.Verify(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), It.IsAny<ParsedMovieInfo>(), true, false), Times.Once());
}
[Test]
public void should_not_use_folder_if_file_import()
{
GivenValidMovie();
var fileName = @"C:\media\ba09030e-1234-1234-1234-123456789abc\Torrents\[HorribleSubs] 47 Ronin (2013) [720p].mkv".AsOsAgnostic();
Mocker.GetMock<IDiskProvider>().Setup(c => c.FolderExists(fileName))
.Returns(false);
Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(fileName))
.Returns(true);
var localMovie = new LocalMovie();
var imported = new List<ImportDecision>();
imported.Add(new ImportDecision(localMovie));
var result = Subject.ProcessPath(fileName);
Mocker.GetMock<IMakeImportDecision>()
.Verify(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), null, true, false), Times.Once());
}
[Test]
public void should_not_process_if_file_and_folder_do_not_exist()
{
var folderName = @"C:\media\ba09030e-1234-1234-1234-123456789abc\[HorribleSubs] 47 Ronin (2013) [720p]".AsOsAgnostic();
Mocker.GetMock<IDiskProvider>().Setup(c => c.FolderExists(folderName))
.Returns(false);
Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(folderName))
.Returns(false);
Subject.ProcessPath(folderName).Should().BeEmpty();
Mocker.GetMock<IParsingService>()
.Verify(v => v.GetMovie(It.IsAny<string>()), Times.Never());
ExceptionVerification.ExpectedErrors(1);
}
[Test]
public void should_not_delete_if_no_files_were_imported()
{
GivenValidMovie();
var localMovie = new LocalMovie();
var imported = new List<ImportDecision>();
imported.Add(new ImportDecision(localMovie));
Mocker.GetMock<IMakeImportDecision>()
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), null, true))
.Returns(imported);
Mocker.GetMock<IImportApprovedEpisodes>()
.Setup(s => s.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto))
.Returns(new List<ImportResult>());
Mocker.GetMock<IDetectSample>()
.Setup(s => s.IsSample(It.IsAny<Movie>(),
It.IsAny<QualityModel>(),
It.IsAny<string>(),
It.IsAny<long>(),
It.IsAny<bool>()))
.Returns(true);
Mocker.GetMock<IDiskProvider>()
.Setup(s => s.GetFileSize(It.IsAny<string>()))
.Returns(15.Megabytes());
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
Mocker.GetMock<IDiskProvider>()
.Verify(v => v.DeleteFolder(It.IsAny<string>(), true), Times.Never());
}
private void VerifyNoImport()
{
Mocker.GetMock<IImportApprovedEpisodes>().Verify(c => c.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto),
Times.Never());
}
private void VerifyImport()
{
Mocker.GetMock<IImportApprovedEpisodes>().Verify(c => c.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto),
Times.Once());
}
}
}

@ -15,8 +15,8 @@ namespace NzbDrone.Core.Test.Messaging.Commands
[Test]
public void should_return_true_when_there_are_no_properties()
{
var command1 = new DownloadedEpisodesScanCommand();
var command2 = new DownloadedEpisodesScanCommand();
var command1 = new DownloadedMoviesScanCommand();
var command2 = new DownloadedMoviesScanCommand();
CommandEqualityComparer.Instance.Equals(command1, command2).Should().BeTrue();
}

@ -272,8 +272,8 @@
<Compile Include="MediaCoverTests\ImageResizerFixture.cs" />
<Compile Include="MediaCoverTests\MediaCoverServiceFixture.cs" />
<Compile Include="MediaFiles\DiskScanServiceTests\ScanFixture.cs" />
<Compile Include="MediaFiles\DownloadedEpisodesCommandServiceFixture.cs" />
<Compile Include="MediaFiles\DownloadedEpisodesImportServiceFixture.cs" />
<Compile Include="MediaFiles\DownloadedMoviesCommandServiceFixture.cs" />
<Compile Include="MediaFiles\DownloadedMoviesImportServiceFixture.cs" />
<Compile Include="MediaFiles\EpisodeFileMovingServiceTests\MoveEpisodeFileFixture.cs" />
<Compile Include="MediaFiles\EpisodeImport\ImportDecisionMakerFixture.cs" />
<Compile Include="MediaFiles\EpisodeImport\SampleServiceFixture.cs" />
@ -590,4 +590,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

@ -103,7 +103,7 @@ namespace NzbDrone.Core.Test.RootFolderTests
var path = @"C:\TV".AsOsAgnostic();
Mocker.GetMock<IConfigService>()
.SetupGet(s => s.DownloadedEpisodesFolder)
.SetupGet(s => s.DownloadedMoviesFolder)
.Returns(path);
Assert.Throws<InvalidOperationException>(() => Subject.Add(new RootFolder { Path = path }));

@ -13,7 +13,7 @@ namespace NzbDrone.Core.Configuration
{
public enum ConfigKey
{
DownloadedEpisodesFolder
DownloadedMoviesFolder
}
public class ConfigService : IConfigService
@ -73,11 +73,11 @@ namespace NzbDrone.Core.Configuration
return _repository.Get(key.ToLower()) != null;
}
public string DownloadedEpisodesFolder
public string DownloadedMoviesFolder
{
get { return GetValue(ConfigKey.DownloadedEpisodesFolder.ToString()); }
get { return GetValue(ConfigKey.DownloadedMoviesFolder.ToString()); }
set { SetValue(ConfigKey.DownloadedEpisodesFolder.ToString(), value); }
set { SetValue(ConfigKey.DownloadedMoviesFolder.ToString(), value); }
}
public bool AutoUnmonitorPreviouslyDownloadedEpisodes
@ -231,11 +231,11 @@ namespace NzbDrone.Core.Configuration
set { SetValue("DownloadClientWorkingFolders", value); }
}
public int DownloadedEpisodesScanInterval
public int DownloadedMoviesScanInterval
{
get { return GetValueInt("DownloadedEpisodesScanInterval", 0); }
get { return GetValueInt("DownloadedMoviesScanInterval", 0); }
set { SetValue("DownloadedEpisodesScanInterval", value); }
set { SetValue("DownloadedMoviesScanInterval", value); }
}
public int DownloadClientHistoryLimit

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Common.Http.Proxy;
@ -11,9 +11,9 @@ namespace NzbDrone.Core.Configuration
bool IsDefined(string key);
//Download Client
string DownloadedEpisodesFolder { get; set; }
string DownloadedMoviesFolder { get; set; }
string DownloadClientWorkingFolders { get; set; }
int DownloadedEpisodesScanInterval { get; set; }
int DownloadedMoviesScanInterval { get; set; }
int DownloadClientHistoryLimit { get; set; }
//Completed/Failed Download Handling (Download client)

@ -49,9 +49,9 @@ namespace NzbDrone.Core.DiskSpace
private IEnumerable<DiskSpace> GetDroneFactoryFreeSpace()
{
if (!string.IsNullOrWhiteSpace(_configService.DownloadedEpisodesFolder))
if (!string.IsNullOrWhiteSpace(_configService.DownloadedMoviesFolder))
{
return GetDiskSpace(new[] { _diskProvider.GetPathRoot(_configService.DownloadedEpisodesFolder) });
return GetDiskSpace(new[] { _diskProvider.GetPathRoot(_configService.DownloadedMoviesFolder) });
}
return new List<DiskSpace>();

@ -127,7 +127,7 @@ namespace NzbDrone.Core.Download.Clients.Pneumatic
if (Settings.StrmFolder.IsNullOrWhiteSpace())
{
folder = _configService.DownloadedEpisodesFolder;
folder = _configService.DownloadedMoviesFolder;
if (folder.IsNullOrWhiteSpace())
{

@ -26,7 +26,6 @@ namespace NzbDrone.Core.Download
private readonly IConfigService _configService;
private readonly IEventAggregator _eventAggregator;
private readonly IHistoryService _historyService;
private readonly IDownloadedEpisodesImportService _downloadedEpisodesImportService;
private readonly IDownloadedMovieImportService _downloadedMovieImportService;
private readonly IParsingService _parsingService;
private readonly IMovieService _movieService;
@ -36,7 +35,6 @@ namespace NzbDrone.Core.Download
public CompletedDownloadService(IConfigService configService,
IEventAggregator eventAggregator,
IHistoryService historyService,
IDownloadedEpisodesImportService downloadedEpisodesImportService,
IDownloadedMovieImportService downloadedMovieImportService,
IParsingService parsingService,
ISeriesService seriesService,
@ -46,7 +44,6 @@ namespace NzbDrone.Core.Download
_configService = configService;
_eventAggregator = eventAggregator;
_historyService = historyService;
_downloadedEpisodesImportService = downloadedEpisodesImportService;
_downloadedMovieImportService = downloadedMovieImportService;
_parsingService = parsingService;
_movieService = movieService;
@ -86,9 +83,9 @@ namespace NzbDrone.Core.Download
return;
}
var downloadedEpisodesFolder = new OsPath(_configService.DownloadedEpisodesFolder);
var downloadedMoviesFolder = new OsPath(_configService.DownloadedMoviesFolder);
if (downloadedEpisodesFolder.Contains(downloadItemOutputPath))
if (downloadedMoviesFolder.Contains(downloadItemOutputPath))
{
trackedDownload.Warn("Intermediate Download path inside drone factory, Skipping.");
return;

@ -17,7 +17,7 @@ namespace NzbDrone.Core.HealthCheck.Checks
public override HealthCheck Check()
{
var droneFactoryFolder = _configService.DownloadedEpisodesFolder;
var droneFactoryFolder = _configService.DownloadedMoviesFolder;
if (droneFactoryFolder.IsNullOrWhiteSpace())
{

@ -24,7 +24,7 @@ namespace NzbDrone.Core.HealthCheck.Checks
public override HealthCheck Check()
{
var droneFactoryFolder = new OsPath(_configService.DownloadedEpisodesFolder);
var droneFactoryFolder = new OsPath(_configService.DownloadedMoviesFolder);
List<ImportMechanismCheckStatus> downloadClients;
try

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using NLog;
@ -94,9 +94,9 @@ namespace NzbDrone.Core.Jobs
new ScheduledTask
{
Interval = _configService.DownloadedEpisodesScanInterval,
TypeName = typeof(DownloadedEpisodesScanCommand).FullName
//TypeName = typeof(DownloadedMovieScanCommand).FullName
Interval = _configService.DownloadedMoviesScanInterval,
//TypeName = typeof(DownloadedEpisodesScanCommand).FullName
TypeName = typeof(DownloadedMoviesScanCommand).FullName
},
};
@ -178,13 +178,13 @@ namespace NzbDrone.Core.Jobs
var rss = _scheduledTaskRepository.GetDefinition(typeof(RssSyncCommand));
rss.Interval = _configService.RssSyncInterval;
var downloadedEpisodes = _scheduledTaskRepository.GetDefinition(typeof(DownloadedEpisodesScanCommand));
downloadedEpisodes.Interval = _configService.DownloadedEpisodesScanInterval;
var downloadedMovies = _scheduledTaskRepository.GetDefinition(typeof(DownloadedMoviesScanCommand));
downloadedMovies.Interval = _configService.DownloadedMoviesScanInterval;
var netImport = _scheduledTaskRepository.GetDefinition(typeof(NetImportSyncCommand));
netImport.Interval = _configService.NetImportSyncInterval;
_scheduledTaskRepository.UpdateMany(new List<ScheduledTask> { rss, downloadedEpisodes, netImport });
_scheduledTaskRepository.UpdateMany(new List<ScheduledTask> { rss, downloadedMovies, netImport });
}
}
}

@ -3,7 +3,7 @@ using NzbDrone.Core.Messaging.Commands;
namespace NzbDrone.Core.MediaFiles.Commands
{
public class DownloadedMovieScanCommand : Command
public class DownloadedMoviesScanCommand : Command
{
public override bool SendUpdatesToClient => SendUpdates;

@ -14,7 +14,7 @@ using System.Text;
namespace NzbDrone.Core.MediaFiles
{
public class DownloadedMovieCommandService : IExecute<DownloadedMovieScanCommand>
public class DownloadedMovieCommandService : IExecute<DownloadedMoviesScanCommand>
{
private readonly IDownloadedMovieImportService _downloadedMovieImportService;
private readonly ITrackedDownloadService _trackedDownloadService;
@ -37,24 +37,24 @@ namespace NzbDrone.Core.MediaFiles
private List<ImportResult> ProcessDroneFactoryFolder()
{
var downloadedEpisodesFolder = _configService.DownloadedEpisodesFolder;
var downloadedMoviesFolder = _configService.DownloadedMoviesFolder;
if (string.IsNullOrEmpty(downloadedEpisodesFolder))
if (string.IsNullOrEmpty(downloadedMoviesFolder))
{
_logger.Trace("Drone Factory folder is not configured");
return new List<ImportResult>();
}
if (!_diskProvider.FolderExists(downloadedEpisodesFolder))
if (!_diskProvider.FolderExists(downloadedMoviesFolder))
{
_logger.Warn("Drone Factory folder [{0}] doesn't exist.", downloadedEpisodesFolder);
_logger.Warn("Drone Factory folder [{0}] doesn't exist.", downloadedMoviesFolder);
return new List<ImportResult>();
}
return _downloadedMovieImportService.ProcessRootFolder(new DirectoryInfo(downloadedEpisodesFolder));
return _downloadedMovieImportService.ProcessRootFolder(new DirectoryInfo(downloadedMoviesFolder));
}
private List<ImportResult> ProcessPath(DownloadedMovieScanCommand message)
private List<ImportResult> ProcessPath(DownloadedMoviesScanCommand message)
{
if (!_diskProvider.FolderExists(message.Path) && !_diskProvider.FileExists(message.Path))
{
@ -83,7 +83,7 @@ namespace NzbDrone.Core.MediaFiles
return _downloadedMovieImportService.ProcessPath(message.Path, message.ImportMode);
}
public void Execute(DownloadedMovieScanCommand message)
public void Execute(DownloadedMoviesScanCommand message)
{
List<ImportResult> importResults;

@ -258,7 +258,7 @@ namespace NzbDrone.Core.MediaFiles
private ImportResult UnknownMovieResult(string message, string videoFile = null)
{
var localEpisode = videoFile == null ? null : new LocalEpisode { Path = videoFile };
var localEpisode = videoFile == null ? null : new LocalMovie { Path = videoFile };
return new ImportResult(new ImportDecision(localEpisode, new Rejection("Unknown Movie")), message);
}

@ -20,7 +20,8 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Series series);
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie);
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, bool shouldCheckQuality);
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, ParsedMovieInfo folderInfo, bool sceneSource, bool shouldCheckQuality); //TODO: Needs changing to ParsedMovieInfo!!
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, ParsedMovieInfo folderInfo, bool sceneSource, bool shouldCheckQuality);
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, ParsedMovieInfo folderInfo, bool sceneSource);
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Series series, ParsedEpisodeInfo folderInfo, bool sceneSource);
}
@ -86,6 +87,23 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
return decisions;
}
public List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, ParsedMovieInfo folderInfo, bool sceneSource)
{
var newFiles = _mediaFileService.FilterExistingFiles(videoFiles.ToList(), movie);
_logger.Debug("Analyzing {0}/{1} files.", newFiles.Count, videoFiles.Count());
var shouldUseFolderName = ShouldUseFolderName(videoFiles, movie, folderInfo);
var decisions = new List<ImportDecision>();
foreach (var file in newFiles)
{
decisions.AddIfNotNull(GetDecision(file, movie, folderInfo, sceneSource, shouldUseFolderName));
}
return decisions;
}
public List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, ParsedMovieInfo folderInfo, bool sceneSource, bool shouldCheckQuality = false)
{
var newFiles = _mediaFileService.FilterExistingFiles(videoFiles.ToList(), movie);

@ -36,7 +36,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
private readonly IImportApprovedEpisodes _importApprovedEpisodes;
private readonly IImportApprovedMovie _importApprovedMovie;
private readonly ITrackedDownloadService _trackedDownloadService;
private readonly IDownloadedEpisodesImportService _downloadedEpisodesImportService;
private readonly IDownloadedMovieImportService _downloadedMovieImportService;
private readonly IEventAggregator _eventAggregator;
private readonly Logger _logger;
@ -52,7 +51,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
IImportApprovedEpisodes importApprovedEpisodes,
IImportApprovedMovie importApprovedMovie,
ITrackedDownloadService trackedDownloadService,
IDownloadedEpisodesImportService downloadedEpisodesImportService,
IDownloadedMovieImportService downloadedMovieImportService,
IEventAggregator eventAggregator,
Logger logger)
@ -68,7 +66,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
_importApprovedEpisodes = importApprovedEpisodes;
_importApprovedMovie = importApprovedMovie;
_trackedDownloadService = trackedDownloadService;
_downloadedEpisodesImportService = downloadedEpisodesImportService;
_downloadedMovieImportService = downloadedMovieImportService;
_eventAggregator = eventAggregator;
_logger = logger;

@ -787,7 +787,6 @@
<Compile Include="MediaCover\MediaCoversUpdatedEvent.cs" />
<Compile Include="MediaFiles\Commands\BackendCommandAttribute.cs" />
<Compile Include="MediaFiles\Commands\CleanUpRecycleBinCommand.cs" />
<Compile Include="MediaFiles\Commands\DownloadedEpisodesScanCommand.cs" />
<Compile Include="MediaFiles\Commands\DownloadedMovieScanCommand.cs" />
<Compile Include="MediaFiles\Commands\RenameMovieCommand.cs" />
<Compile Include="MediaFiles\Commands\RenameMovieFilesCommand.cs" />
@ -812,10 +811,6 @@
<Compile Include="MediaFiles\DiskScanService.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="MediaFiles\DownloadedEpisodesImportService.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="MediaFiles\DownloadedEpisodesCommandService.cs" />
<Compile Include="MediaFiles\EpisodeFile.cs" />
<Compile Include="MediaFiles\EpisodeFileMoveResult.cs" />
<Compile Include="MediaFiles\EpisodeFileMovingService.cs" />

@ -110,7 +110,7 @@ namespace NzbDrone.Core.RootFolders
throw new InvalidOperationException("Recent directory already exists.");
}
if (_configService.DownloadedEpisodesFolder.IsNotNullOrWhiteSpace() && _configService.DownloadedEpisodesFolder.PathEquals(rootFolder.Path))
if (_configService.DownloadedMoviesFolder.IsNotNullOrWhiteSpace() && _configService.DownloadedMoviesFolder.PathEquals(rootFolder.Path))
{
throw new InvalidOperationException("Drone Factory folder cannot be used.");
}

@ -18,7 +18,7 @@ namespace NzbDrone.Core.Validation.Paths
{
if (context.PropertyValue == null) return false;
var droneFactory = _configService.DownloadedEpisodesFolder;
var droneFactory = _configService.DownloadedMoviesFolder;
if (string.IsNullOrWhiteSpace(droneFactory)) return true;

@ -10,7 +10,7 @@
</div>
<div class="col-sm-8 col-sm-pull-1">
<input type="text" name="downloadedEpisodesFolder" class="form-control x-path" />
<input type="text" name="downloadedMoviesFolder" class="form-control x-path" />
</div>
</div>
@ -23,7 +23,7 @@
</div>
<div class="col-sm-2 col-sm-pull-1">
<input type="number" name="downloadedEpisodesScanInterval" class="form-control" />
<input type="number" name="downloadedMoviesScanInterval" class="form-control" />
</div>
</div>
</fieldset>
Loading…
Cancel
Save