mirror of
https://github.com/Sonarr/Sonarr.git
synced 2026-04-25 22:46:31 -04:00
Add reason enum to decision engine rejections
This commit is contained in:
@@ -6,7 +6,6 @@ using NLog;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
||||
using NzbDrone.Core.Parser;
|
||||
@@ -178,7 +177,7 @@ namespace NzbDrone.Core.MediaFiles
|
||||
_logger.Warn("Unable to process folder that is mapped to an existing series");
|
||||
return new List<ImportResult>
|
||||
{
|
||||
RejectionResult("Import path is mapped to a series folder")
|
||||
RejectionResult(ImportRejectionReason.SeriesFolder, "Import path is mapped to a series folder")
|
||||
};
|
||||
}
|
||||
|
||||
@@ -255,7 +254,7 @@ namespace NzbDrone.Core.MediaFiles
|
||||
|
||||
return new List<ImportResult>
|
||||
{
|
||||
new ImportResult(new ImportDecision(new LocalEpisode { Path = fileInfo.FullName }, new Rejection("Invalid video file, filename starts with '._'")), "Invalid video file, filename starts with '._'")
|
||||
new ImportResult(new ImportDecision(new LocalEpisode { Path = fileInfo.FullName }, new ImportRejection(ImportRejectionReason.InvalidFilePath, "Invalid video file, filename starts with '._'")), "Invalid video file, filename starts with '._'")
|
||||
};
|
||||
}
|
||||
|
||||
@@ -268,7 +267,7 @@ namespace NzbDrone.Core.MediaFiles
|
||||
return new List<ImportResult>
|
||||
{
|
||||
new ImportResult(new ImportDecision(new LocalEpisode { Path = fileInfo.FullName },
|
||||
new Rejection($"Invalid video file, unsupported extension: '{extension}'")),
|
||||
new ImportRejection(ImportRejectionReason.UnsupportedExtension, $"Invalid video file, unsupported extension: '{extension}'")),
|
||||
$"Invalid video file, unsupported extension: '{extension}'")
|
||||
};
|
||||
}
|
||||
@@ -300,19 +299,19 @@ namespace NzbDrone.Core.MediaFiles
|
||||
private ImportResult FileIsLockedResult(string videoFile)
|
||||
{
|
||||
_logger.Debug("[{0}] is currently locked by another process, skipping", videoFile);
|
||||
return new ImportResult(new ImportDecision(new LocalEpisode { Path = videoFile }, new Rejection("Locked file, try again later")), "Locked file, try again later");
|
||||
return new ImportResult(new ImportDecision(new LocalEpisode { Path = videoFile }, new ImportRejection(ImportRejectionReason.FileLocked, "Locked file, try again later")), "Locked file, try again later");
|
||||
}
|
||||
|
||||
private ImportResult UnknownSeriesResult(string message, string videoFile = null)
|
||||
{
|
||||
var localEpisode = videoFile == null ? null : new LocalEpisode { Path = videoFile };
|
||||
|
||||
return new ImportResult(new ImportDecision(localEpisode, new Rejection("Unknown Series")), message);
|
||||
return new ImportResult(new ImportDecision(localEpisode, new ImportRejection(ImportRejectionReason.UnknownSeries, "Unknown Series")), message);
|
||||
}
|
||||
|
||||
private ImportResult RejectionResult(string message)
|
||||
private ImportResult RejectionResult(ImportRejectionReason reason, string message)
|
||||
{
|
||||
return new ImportResult(new ImportDecision(null, new Rejection(message)), message);
|
||||
return new ImportResult(new ImportDecision(null, new ImportRejection(reason, message)), message);
|
||||
}
|
||||
|
||||
private ImportResult CheckEmptyResultForIssue(string folder)
|
||||
@@ -321,12 +320,12 @@ namespace NzbDrone.Core.MediaFiles
|
||||
|
||||
if (files.Any(file => FileExtensions.ExecutableExtensions.Contains(Path.GetExtension(file))))
|
||||
{
|
||||
return RejectionResult("Caution: Found executable file");
|
||||
return RejectionResult(ImportRejectionReason.ExecutableFile, "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 RejectionResult(ImportRejectionReason.ArchiveFile, "Found archive file, might need to be extracted");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user