Fixed: Better error messaging when import fails due to inaccessible path

pull/6/head
Mark McDowall 10 years ago
parent c3d15015fe
commit 2a4fd2bbde

@ -202,6 +202,9 @@ namespace NzbDrone.Core.Test.MediaFiles
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);
@ -275,7 +278,7 @@ namespace NzbDrone.Core.Test.MediaFiles
imported.Add(new ImportDecision(localEpisode));
var result = Subject.ProcessPath(fileName);
Subject.ProcessPath(fileName);
Mocker.GetMock<IMakeImportDecision>()
.Verify(s => s.GetImportDecisions(It.IsAny<List<String>>(), It.IsAny<Series>(), It.Is<ParsedEpisodeInfo>(v => v.AbsoluteEpisodeNumbers.First() == 9), true), Times.Once());
@ -291,6 +294,9 @@ namespace NzbDrone.Core.Test.MediaFiles
Mocker.GetMock<IDiskProvider>().Setup(c => c.FolderExists(fileName))
.Returns(false);
Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(fileName))
.Returns(true);
var localEpisode = new LocalEpisode();
var imported = new List<ImportDecision>();
@ -302,6 +308,25 @@ namespace NzbDrone.Core.Test.MediaFiles
.Verify(s => s.GetImportDecisions(It.IsAny<List<String>>(), It.IsAny<Series>(), null, true), 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] Maria the Virgin Witch - 09 [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.GetSeries(It.IsAny<string>()), Times.Never());
ExceptionVerification.ExpectedErrors(1);
}
private void VerifyNoImport()
{
Mocker.GetMock<IImportApprovedEpisodes>().Verify(c => c.Import(It.IsAny<List<ImportDecision>>(), true, null),

@ -82,6 +82,8 @@ namespace NzbDrone.Core.MediaFiles
return ProcessFolder(directoryInfo, series, downloadClientItem);
}
if (_diskProvider.FileExists(path))
{
var fileInfo = new FileInfo(path);
if (series == null)
@ -92,6 +94,10 @@ namespace NzbDrone.Core.MediaFiles
return ProcessFile(fileInfo, series, downloadClientItem);
}
_logger.Error("Import failed, path does not exist or is not accessible by Sonarr: {0}", path);
return new List<ImportResult>();
}
private List<ImportResult> ProcessFolder(DirectoryInfo directoryInfo, DownloadClientItem downloadClientItem = null)
{
var cleanedUpName = GetCleanedUpFolderName(directoryInfo.Name);

Loading…
Cancel
Save