mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-28 23:07:13 -04:00
Fixed: Backend Updates from Sonarr
Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com> Co-Authored-By: taloth <taloth@users.noreply.github.com>
This commit is contained in:
@@ -6,7 +6,9 @@ using System.Linq;
|
||||
using FluentValidation.Results;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Processes;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
@@ -29,6 +31,8 @@ namespace NzbDrone.Core.Notifications.CustomScript
|
||||
|
||||
public override string Link => "https://github.com/Radarr/Radarr/wiki/Custom-Post-Processing-Scripts";
|
||||
|
||||
public override ProviderMessage Message => new ProviderMessage("Testing will execute the script with the EventType set to Test, ensure your script handles this correctly", ProviderMessageType.Warning);
|
||||
|
||||
public override void OnGrab(GrabMessage message)
|
||||
{
|
||||
var movie = message.Movie;
|
||||
@@ -84,6 +88,7 @@ namespace NzbDrone.Core.Notifications.CustomScript
|
||||
environmentVariables.Add("Radarr_DeletedRelativePaths", string.Join("|", message.OldMovieFiles.Select(e => e.RelativePath)));
|
||||
environmentVariables.Add("Radarr_DeletedPaths", string.Join("|", message.OldMovieFiles.Select(e => Path.Combine(movie.Path, e.RelativePath))));
|
||||
}
|
||||
|
||||
ExecuteScript(environmentVariables);
|
||||
}
|
||||
|
||||
@@ -110,22 +115,33 @@ namespace NzbDrone.Core.Notifications.CustomScript
|
||||
failures.Add(new NzbDroneValidationFailure("Path", "File does not exist"));
|
||||
}
|
||||
|
||||
try
|
||||
foreach (var systemFolder in SystemFolders.GetSystemFolders())
|
||||
{
|
||||
var environmentVariables = new StringDictionary();
|
||||
environmentVariables.Add("Radarr_EventType", "Test");
|
||||
|
||||
var processOutput = ExecuteScript(environmentVariables);
|
||||
|
||||
if (processOutput.ExitCode != 0)
|
||||
if (systemFolder.IsParentPath(Settings.Path))
|
||||
{
|
||||
failures.Add(new NzbDroneValidationFailure(string.Empty, $"Script exited with code: {processOutput.ExitCode}"));
|
||||
failures.Add(new NzbDroneValidationFailure("Path", $"Must not be a descendant of '{systemFolder}'"));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
if (failures.Empty())
|
||||
{
|
||||
_logger.Error(ex);
|
||||
failures.Add(new NzbDroneValidationFailure(string.Empty, ex.Message));
|
||||
try
|
||||
{
|
||||
var environmentVariables = new StringDictionary();
|
||||
environmentVariables.Add("Radarr_EventType", "Test");
|
||||
|
||||
var processOutput = ExecuteScript(environmentVariables);
|
||||
|
||||
if (processOutput.ExitCode != 0)
|
||||
{
|
||||
failures.Add(new NzbDroneValidationFailure(string.Empty, $"Script exited with code: {processOutput.ExitCode}"));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex);
|
||||
failures.Add(new NzbDroneValidationFailure(string.Empty, ex.Message));
|
||||
}
|
||||
}
|
||||
|
||||
return new ValidationResult(failures);
|
||||
@@ -142,5 +158,10 @@ namespace NzbDrone.Core.Notifications.CustomScript
|
||||
|
||||
return processOutput;
|
||||
}
|
||||
|
||||
private bool ValidatePathParent(string possibleParent, string path)
|
||||
{
|
||||
return possibleParent.IsParentPath(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace NzbDrone.Core.Notifications.CustomScript
|
||||
public CustomScriptSettingsValidator()
|
||||
{
|
||||
RuleFor(c => c.Path).IsValidPath();
|
||||
RuleFor(c => c.Arguments).Empty().WithMessage("Arguments are no longer supported for custom scripts");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +22,7 @@ namespace NzbDrone.Core.Notifications.CustomScript
|
||||
[FieldDefinition(0, Label = "Path", Type = FieldType.FilePath)]
|
||||
public string Path { get; set; }
|
||||
|
||||
[FieldDefinition(1, Label = "Arguments", HelpText = "Arguments to pass to the script")]
|
||||
[FieldDefinition(1, Label = "Arguments", HelpText = "Arguments to pass to the script", Hidden = HiddenType.HiddenIfNotSet)]
|
||||
public string Arguments { get; set; }
|
||||
|
||||
public NzbDroneValidationResult Validate()
|
||||
|
||||
Reference in New Issue
Block a user