mirror of
https://github.com/Radarr/Radarr.git
synced 2025-04-23 22:17:15 -04:00
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 (cherry picked from commit b15b6a079846b21cac8476820fce9cde81732291)
This commit is contained in:
parent
d4ce08a044
commit
ce031124c7
4 changed files with 134 additions and 5 deletions
|
@ -445,6 +445,58 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
.Verify(v => v.DeleteFolder(It.IsAny<string>(), true), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_rejection_if_nothing_imported_and_contains_rar_file()
|
||||
{
|
||||
GivenValidMovie();
|
||||
|
||||
var path = @"C:\media\ba09030e-1234-1234-1234-123456789abc\[HorribleSubs] American Psycho (2000) [720p]\[HorribleSubs] American Psycho (2000) [720p].mkv".AsOsAgnostic();
|
||||
var imported = new List<ImportDecision>();
|
||||
|
||||
Mocker.GetMock<IMakeImportDecision>()
|
||||
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), It.IsAny<DownloadClientItem>(), null, true, 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<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()
|
||||
{
|
||||
GivenValidMovie();
|
||||
|
||||
var path = @"C:\media\ba09030e-1234-1234-1234-123456789abc\[HorribleSubs] American Psycho (2000) [720p]\[HorribleSubs] American Psycho (2000) [720p].mkv".AsOsAgnostic();
|
||||
var imported = new List<ImportDecision>();
|
||||
|
||||
Mocker.GetMock<IMakeImportDecision>()
|
||||
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), It.IsAny<DownloadClientItem>(), null, true, 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<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()
|
||||
{
|
||||
Mocker.GetMock<IImportApprovedMovie>().Verify(c => c.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto),
|
||||
|
|
|
@ -134,14 +134,33 @@ namespace NzbDrone.Core.Download
|
|||
trackedDownload.Warn("No files found are eligible for import in {0}", outputPath);
|
||||
}
|
||||
|
||||
if (importResults.Count == 1)
|
||||
{
|
||||
var firstResult = importResults.First();
|
||||
|
||||
if (firstResult.Result == ImportResultType.Rejected && firstResult.ImportDecision.LocalMovie == null)
|
||||
{
|
||||
trackedDownload.Warn(new TrackedDownloadStatusMessage(firstResult.Errors.First(), new List<string>()));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var statusMessages = new List<TrackedDownloadStatusMessage>
|
||||
{
|
||||
new TrackedDownloadStatusMessage("One or more movies expected in this release were not imported or missing", new List<string>())
|
||||
};
|
||||
|
||||
if (importResults.Any(c => c.Result != ImportResultType.Imported))
|
||||
{
|
||||
var statusMessages = importResults
|
||||
statusMessages.AddRange(importResults
|
||||
.Where(v => v.Result != ImportResultType.Imported && v.ImportDecision.LocalMovie != null)
|
||||
.Select(v => new TrackedDownloadStatusMessage(Path.GetFileName(v.ImportDecision.LocalMovie.Path), v.Errors))
|
||||
.ToArray();
|
||||
.Select(v => new TrackedDownloadStatusMessage(Path.GetFileName(v.ImportDecision.LocalMovie.Path), v.Errors)));
|
||||
|
||||
trackedDownload.Warn(statusMessages);
|
||||
if (statusMessages.Any())
|
||||
{
|
||||
trackedDownload.Warn(statusMessages.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -184,7 +184,10 @@ namespace NzbDrone.Core.MediaFiles
|
|||
if (_movieService.MoviePathExists(directoryInfo.FullName))
|
||||
{
|
||||
_logger.Warn("Unable to process folder that is mapped to an existing movie");
|
||||
return new List<ImportResult>();
|
||||
return new List<ImportResult>
|
||||
{
|
||||
RejectionResult("Import path is mapped to a movie folder")
|
||||
};
|
||||
}
|
||||
|
||||
var cleanedUpName = GetCleanedUpFolderName(directoryInfo.Name);
|
||||
|
@ -228,6 +231,10 @@ namespace NzbDrone.Core.MediaFiles
|
|||
_logger.Debug("Deleting folder after importing valid files");
|
||||
_diskProvider.DeleteFolder(directoryInfo.FullName, true);
|
||||
}
|
||||
else if (importResults.Empty())
|
||||
{
|
||||
importResults.AddIfNotNull(CheckEmptyResultForIssue(directoryInfo.FullName));
|
||||
}
|
||||
|
||||
return importResults;
|
||||
}
|
||||
|
@ -312,6 +319,28 @@ namespace NzbDrone.Core.MediaFiles
|
|||
return new ImportResult(new ImportDecision(localMovie, new Rejection("Unknown Movie")), 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)
|
||||
{
|
||||
if (_runtimeInfo.IsWindowsService)
|
||||
|
|
29
src/NzbDrone.Core/MediaFiles/FileExtensions.cs
Normal file
29
src/NzbDrone.Core/MediaFiles/FileExtensions.cs
Normal file
|
@ -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…
Add table
Add a link
Reference in a new issue