mirror of https://github.com/Radarr/Radarr
Fixed: Don't mark releases as imported unless at least one file is imported
This commit is contained in:
parent
20894b40cf
commit
b638e09f24
|
@ -449,7 +449,39 @@ namespace NzbDrone.Core.Test.Download
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_mark_as_successful_if_no_files_were_imported()
|
||||
public void should_not_mark_as_imported_if_all_files_were_rejected()
|
||||
{
|
||||
GivenCompletedDownloadClientHistory();
|
||||
|
||||
var history = Builder<History.History>.CreateListOfSize(1)
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
GivenGrabbedHistory(history);
|
||||
GivenNoImportedHistory();
|
||||
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
||||
.Setup(v => v.ProcessFolder(It.IsAny<DirectoryInfo>(), It.IsAny<DownloadClientItem>()))
|
||||
.Returns(new List<ImportResult>
|
||||
{
|
||||
new ImportResult(
|
||||
new ImportDecision(new LocalEpisode() {Path = @"C:\TestPath\Droned.S01E01.mkv"}, "Rejected!"),
|
||||
"Test Failure")
|
||||
});
|
||||
|
||||
history.First().Data.Add("downloadClient", "SabnzbdClient");
|
||||
history.First().Data.Add("downloadClientId", _completed.First().DownloadClientId);
|
||||
|
||||
Subject.Execute(new CheckForFinishedDownloadCommand());
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(c => c.DeleteFolder(It.IsAny<string>(), true), Times.Never());
|
||||
|
||||
ExceptionVerification.ExpectedErrors(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_mark_as_imported_if_all_files_were_skipped()
|
||||
{
|
||||
GivenCompletedDownloadClientHistory();
|
||||
|
||||
|
@ -479,5 +511,38 @@ namespace NzbDrone.Core.Test.Download
|
|||
|
||||
ExceptionVerification.ExpectedErrors(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_mark_as_imported_if_some_files_were_skipped()
|
||||
{
|
||||
GivenCompletedDownloadClientHistory();
|
||||
|
||||
var history = Builder<History.History>.CreateListOfSize(1)
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
GivenGrabbedHistory(history);
|
||||
GivenNoImportedHistory();
|
||||
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
||||
.Setup(v => v.ProcessFolder(It.IsAny<DirectoryInfo>(), It.IsAny<DownloadClientItem>()))
|
||||
.Returns(new List<ImportResult>
|
||||
{
|
||||
new ImportResult(new ImportDecision(new LocalEpisode() {Path = @"C:\TestPath\Droned.S01E01.mkv"})),
|
||||
new ImportResult(
|
||||
new ImportDecision(new LocalEpisode() {Path = @"C:\TestPath\Droned.S01E01.mkv"}),
|
||||
"Test Failure")
|
||||
});
|
||||
|
||||
history.First().Data.Add("downloadClient", "SabnzbdClient");
|
||||
history.First().Data.Add("downloadClientId", _completed.First().DownloadClientId);
|
||||
|
||||
Subject.Execute(new CheckForFinishedDownloadCommand());
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(c => c.DeleteFolder(It.IsAny<string>(), true), Times.Never());
|
||||
|
||||
ExceptionVerification.ExpectedErrors(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,6 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
|||
.Setup(c => c.GetLocalEpisode(It.IsAny<String>(), It.IsAny<Series>(), It.IsAny<Boolean>()))
|
||||
.Returns(_localEpisode);
|
||||
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
.Setup(c => c.FilterExistingFiles(_videoFiles, It.IsAny<Series>()))
|
||||
.Returns(_videoFiles);
|
||||
|
@ -147,12 +146,13 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void failed_parse_shouldnt_blowup_the_process()
|
||||
public void should_not_blowup_the_process_due_to_failed_parse()
|
||||
{
|
||||
GivenSpecifications(_pass1);
|
||||
|
||||
Mocker.GetMock<IParsingService>().Setup(c => c.GetLocalEpisode(It.IsAny<String>(), It.IsAny<Series>(), It.IsAny<Boolean>()))
|
||||
.Throws<TestException>();
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(c => c.GetLocalEpisode(It.IsAny<String>(), It.IsAny<Series>(), It.IsAny<Boolean>()))
|
||||
.Throws<TestException>();
|
||||
|
||||
_videoFiles = new List<String>
|
||||
{
|
||||
|
@ -161,7 +161,6 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
|||
"The.Office.S03E115.DVDRip.XviD-OSiTV"
|
||||
};
|
||||
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
.Setup(c => c.FilterExistingFiles(_videoFiles, It.IsAny<Series>()))
|
||||
.Returns(_videoFiles);
|
||||
|
@ -206,5 +205,31 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
|||
|
||||
result.Single().LocalEpisode.Quality.Should().Be(expectedQuality);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_throw_if_episodes_are_not_found()
|
||||
{
|
||||
GivenSpecifications(_pass1);
|
||||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(c => c.GetLocalEpisode(It.IsAny<String>(), It.IsAny<Series>(), It.IsAny<Boolean>()))
|
||||
.Throws(new EpisodeNotFoundException("Episode not found"));
|
||||
|
||||
_videoFiles = new List<String>
|
||||
{
|
||||
"The.Office.S03E115.DVDRip.XviD-OSiTV",
|
||||
"The.Office.S03E115.DVDRip.XviD-OSiTV",
|
||||
"The.Office.S03E115.DVDRip.XviD-OSiTV"
|
||||
};
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
.Setup(c => c.FilterExistingFiles(_videoFiles, It.IsAny<Series>()))
|
||||
.Returns(_videoFiles);
|
||||
|
||||
Subject.GetImportDecisions(_videoFiles, _series, false);
|
||||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Verify(c => c.GetLocalEpisode(It.IsAny<String>(), It.IsAny<Series>(), It.IsAny<Boolean>()), Times.Exactly(_videoFiles.Count));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -187,7 +187,7 @@ namespace NzbDrone.Core.Download
|
|||
{
|
||||
UpdateStatusMessage(trackedDownload, LogLevel.Error, "No files found are eligible for import in {0}", trackedDownload.DownloadItem.OutputPath);
|
||||
}
|
||||
else if (importResults.All(v => v.Result == ImportResultType.Imported || v.Result == ImportResultType.Rejected))
|
||||
else if (importResults.Any(v => v.Result == ImportResultType.Imported) && importResults.All(v => v.Result == ImportResultType.Imported || v.Result == ImportResultType.Rejected))
|
||||
{
|
||||
UpdateStatusMessage(trackedDownload, LogLevel.Info, "Imported {0} files.", importResults.Count(v => v.Result == ImportResultType.Imported));
|
||||
|
||||
|
|
|
@ -60,10 +60,12 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
|
|||
try
|
||||
{
|
||||
var parsedEpisode = _parsingService.GetLocalEpisode(file, series, sceneSource);
|
||||
|
||||
|
||||
if (parsedEpisode != null)
|
||||
{
|
||||
if (quality != null && new QualityModelComparer(parsedEpisode.Series.Profile).Compare(quality, parsedEpisode.Quality) > 0)
|
||||
if (quality != null &&
|
||||
new QualityModelComparer(parsedEpisode.Series.Profile).Compare(quality,
|
||||
parsedEpisode.Quality) > 0)
|
||||
{
|
||||
_logger.Debug("Using quality from folder: {0}", quality);
|
||||
parsedEpisode.Quality = quality;
|
||||
|
@ -85,9 +87,16 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
|
|||
decision = new ImportDecision(parsedEpisode, "Unable to parse file");
|
||||
}
|
||||
}
|
||||
catch (EpisodeNotFoundException e)
|
||||
{
|
||||
var parsedEpisode = new LocalEpisode();
|
||||
parsedEpisode.Path = file;
|
||||
|
||||
decision = new ImportDecision(parsedEpisode, e.Message);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.ErrorException("Couldn't import file." + file, e);
|
||||
_logger.ErrorException("Couldn't import file. " + file, e);
|
||||
}
|
||||
|
||||
if (decision != null)
|
||||
|
|
|
@ -59,21 +59,30 @@ namespace NzbDrone.Core.Metadata
|
|||
if (metadata.Type == MetadataType.EpisodeImage ||
|
||||
metadata.Type == MetadataType.EpisodeMetadata)
|
||||
{
|
||||
var localEpisode = _parsingService.GetLocalEpisode(possibleMetadataFile, message.Series, false);
|
||||
try
|
||||
{
|
||||
var localEpisode = _parsingService.GetLocalEpisode(possibleMetadataFile, message.Series, false);
|
||||
|
||||
if (localEpisode == null)
|
||||
if (localEpisode == null)
|
||||
{
|
||||
_logger.Debug("Unable to parse meta data file: {0}", possibleMetadataFile);
|
||||
break;
|
||||
}
|
||||
|
||||
if (localEpisode.Episodes.DistinctBy(e => e.EpisodeFileId).Count() > 1)
|
||||
{
|
||||
_logger.Debug("Metadata file: {0} does not match existing files.", possibleMetadataFile);
|
||||
break;
|
||||
}
|
||||
|
||||
metadata.EpisodeFileId = localEpisode.Episodes.First().EpisodeFileId;
|
||||
|
||||
}
|
||||
catch (EpisodeNotFoundException e)
|
||||
{
|
||||
_logger.Debug("Cannot find related episodes for: {0}", possibleMetadataFile);
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (localEpisode.Episodes.DistinctBy(e => e.EpisodeFileId).Count() > 1)
|
||||
{
|
||||
_logger.Debug("Metadata file: {0} does not match existing files.", possibleMetadataFile);
|
||||
break;
|
||||
}
|
||||
|
||||
metadata.EpisodeFileId = localEpisode.Episodes.First().EpisodeFileId;
|
||||
}
|
||||
|
||||
metadataFiles.Add(metadata);
|
||||
|
|
|
@ -652,6 +652,7 @@
|
|||
<Compile Include="Organizer\NamingConfig.cs" />
|
||||
<Compile Include="Organizer\NamingConfigService.cs" />
|
||||
<Compile Include="Organizer\SampleResult.cs" />
|
||||
<Compile Include="Parser\EpisodeNotFoundException.cs" />
|
||||
<Compile Include="Parser\InvalidDateException.cs" />
|
||||
<Compile Include="Parser\Language.cs" />
|
||||
<Compile Include="Parser\Model\LocalEpisode.cs" />
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
using NzbDrone.Common.Exceptions;
|
||||
|
||||
namespace NzbDrone.Core.Parser
|
||||
{
|
||||
public class EpisodeNotFoundException : NzbDroneException
|
||||
{
|
||||
public EpisodeNotFoundException(string message, params object[] args) : base(message, args)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -62,10 +62,10 @@ namespace NzbDrone.Core.Parser
|
|||
|
||||
var episodes = GetEpisodes(parsedEpisodeInfo, series, sceneSource);
|
||||
|
||||
if (!episodes.Any())
|
||||
if (episodes.Empty())
|
||||
{
|
||||
_logger.Debug("No matching episodes found for: {0}", parsedEpisodeInfo);
|
||||
return null;
|
||||
throw new EpisodeNotFoundException("Unable to find episodes for file: {0}", parsedEpisodeInfo);
|
||||
}
|
||||
|
||||
return new LocalEpisode
|
||||
|
|
Loading…
Reference in New Issue