Improve handling of releases without video files
New: Show warning in queue if download contains executable or archive file and no video file was detected Closes #5101
This commit is contained in:
parent
4ce4031dd8
commit
b15b6a0798
|
@ -446,6 +446,58 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
.Verify(v => v.DeleteFolder(It.IsAny<string>(), true), Times.Never());
|
.Verify(v => v.DeleteFolder(It.IsAny<string>(), true), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_rejection_if_nothing_imported_and_contains_rar_file()
|
||||||
|
{
|
||||||
|
GivenValidSeries();
|
||||||
|
|
||||||
|
var path = @"C:\Test\Unsorted\Series.Title.S01E01.abc-Sonarr".AsOsAgnostic();
|
||||||
|
var imported = new List<ImportDecision>();
|
||||||
|
|
||||||
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
|
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>(), null, true, true))
|
||||||
|
.Returns(imported);
|
||||||
|
|
||||||
|
Mocker.GetMock<IImportApprovedEpisodes>()
|
||||||
|
.Setup(s => s.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto))
|
||||||
|
.Returns(imported.Select(i => new ImportResult(i)).ToList());
|
||||||
|
|
||||||
|
Mocker.GetMock<IDiskProvider>()
|
||||||
|
.Setup(s => s.GetFiles(It.IsAny<string>(), SearchOption.AllDirectories))
|
||||||
|
.Returns(new[] { _videoFiles.First().Replace(".ext", ".rar") });
|
||||||
|
|
||||||
|
var result = Subject.ProcessPath(path);
|
||||||
|
|
||||||
|
result.Count.Should().Be(1);
|
||||||
|
result.First().Result.Should().Be(ImportResultType.Rejected);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_rejection_if_nothing_imported_and_contains_executable_file()
|
||||||
|
{
|
||||||
|
GivenValidSeries();
|
||||||
|
|
||||||
|
var path = @"C:\Test\Unsorted\Series.Title.S01E01.abc-Sonarr".AsOsAgnostic();
|
||||||
|
var imported = new List<ImportDecision>();
|
||||||
|
|
||||||
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
|
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>(), null, true, true))
|
||||||
|
.Returns(imported);
|
||||||
|
|
||||||
|
Mocker.GetMock<IImportApprovedEpisodes>()
|
||||||
|
.Setup(s => s.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto))
|
||||||
|
.Returns(imported.Select(i => new ImportResult(i)).ToList());
|
||||||
|
|
||||||
|
Mocker.GetMock<IDiskProvider>()
|
||||||
|
.Setup(s => s.GetFiles(It.IsAny<string>(), SearchOption.AllDirectories))
|
||||||
|
.Returns(new[] { _videoFiles.First().Replace(".ext", ".exe") });
|
||||||
|
|
||||||
|
var result = Subject.ProcessPath(path);
|
||||||
|
|
||||||
|
result.Count.Should().Be(1);
|
||||||
|
result.First().Result.Should().Be(ImportResultType.Rejected);
|
||||||
|
}
|
||||||
|
|
||||||
private void VerifyNoImport()
|
private void VerifyNoImport()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<IImportApprovedEpisodes>().Verify(c => c.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto),
|
Mocker.GetMock<IImportApprovedEpisodes>().Verify(c => c.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto),
|
||||||
|
|
|
@ -147,6 +147,18 @@ namespace NzbDrone.Core.Download
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (importResults.Count == 1)
|
||||||
|
{
|
||||||
|
var firstResult = importResults.First();
|
||||||
|
|
||||||
|
if (firstResult.Result == ImportResultType.Rejected && firstResult.ImportDecision.LocalEpisode == null)
|
||||||
|
{
|
||||||
|
trackedDownload.Warn(new TrackedDownloadStatusMessage(firstResult.Errors.First(), new List<string>()));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var statusMessages = new List<TrackedDownloadStatusMessage>
|
var statusMessages = new List<TrackedDownloadStatusMessage>
|
||||||
{
|
{
|
||||||
new TrackedDownloadStatusMessage("One or more episodes expected in this release were not imported or missing", new List<string>())
|
new TrackedDownloadStatusMessage("One or more episodes expected in this release were not imported or missing", new List<string>())
|
||||||
|
|
|
@ -175,8 +175,11 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
{
|
{
|
||||||
if (_seriesService.SeriesPathExists(directoryInfo.FullName))
|
if (_seriesService.SeriesPathExists(directoryInfo.FullName))
|
||||||
{
|
{
|
||||||
_logger.Warn("Unable to process folder that is mapped to an existing show");
|
_logger.Warn("Unable to process folder that is mapped to an existing series");
|
||||||
return new List<ImportResult>();
|
return new List<ImportResult>
|
||||||
|
{
|
||||||
|
RejectionResult("Import path is mapped to a series folder")
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var folderInfo = Parser.Parser.ParseTitle(directoryInfo.Name);
|
var folderInfo = Parser.Parser.ParseTitle(directoryInfo.Name);
|
||||||
|
@ -211,6 +214,10 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
_logger.Debug("Deleting folder after importing valid files");
|
_logger.Debug("Deleting folder after importing valid files");
|
||||||
_diskProvider.DeleteFolder(directoryInfo.FullName, true);
|
_diskProvider.DeleteFolder(directoryInfo.FullName, true);
|
||||||
}
|
}
|
||||||
|
else if (importResults.Empty())
|
||||||
|
{
|
||||||
|
importResults.AddIfNotNull(CheckEmptyResultForIssue(directoryInfo.FullName));
|
||||||
|
}
|
||||||
|
|
||||||
return importResults;
|
return importResults;
|
||||||
}
|
}
|
||||||
|
@ -295,6 +302,28 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
return new ImportResult(new ImportDecision(localEpisode, new Rejection("Unknown Series")), message);
|
return new ImportResult(new ImportDecision(localEpisode, new Rejection("Unknown Series")), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ImportResult RejectionResult(string message)
|
||||||
|
{
|
||||||
|
return new ImportResult(new ImportDecision(null, new Rejection(message)), message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ImportResult CheckEmptyResultForIssue(string folder)
|
||||||
|
{
|
||||||
|
var files = _diskProvider.GetFiles(folder, SearchOption.AllDirectories);
|
||||||
|
|
||||||
|
if (files.Any(file => FileExtensions.ExecutableExtensions.Contains(Path.GetExtension(file))))
|
||||||
|
{
|
||||||
|
return RejectionResult("Caution: Found executable file");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (files.Any(file => FileExtensions.ArchiveExtensions.Contains(Path.GetExtension(file))))
|
||||||
|
{
|
||||||
|
return RejectionResult("Found archive file, might need to be extracted");
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private void LogInaccessiblePathError(string path)
|
private void LogInaccessiblePathError(string path)
|
||||||
{
|
{
|
||||||
if (_runtimeInfo.IsWindowsService)
|
if (_runtimeInfo.IsWindowsService)
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.MediaFiles
|
||||||
|
{
|
||||||
|
internal static class FileExtensions
|
||||||
|
{
|
||||||
|
private static List<string> _archiveExtensions = new List<string>
|
||||||
|
{
|
||||||
|
".rar",
|
||||||
|
".r00",
|
||||||
|
".zip",
|
||||||
|
".tar",
|
||||||
|
".gz",
|
||||||
|
".tar.gz"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static List<string> _executableExtensions = new List<string>
|
||||||
|
{
|
||||||
|
".exe",
|
||||||
|
".bat",
|
||||||
|
".cmd",
|
||||||
|
".sh"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static HashSet<string> ArchiveExtensions => new HashSet<string>(_archiveExtensions, StringComparer.OrdinalIgnoreCase);
|
||||||
|
public static HashSet<string> ExecutableExtensions => new HashSet<string>(_executableExtensions, StringComparer.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue