Fixed: Unable to execute custom scripts if IMDB ID is null (#2543)

fixes #1460
This commit is contained in:
Qstick
2018-02-19 08:19:14 +01:00
committed by Leonardo Galli
parent ae88645180
commit d0406ced40
2 changed files with 30 additions and 12 deletions
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
@@ -98,9 +98,9 @@ namespace NzbDrone.Common.Processes
var process = new Process
{
StartInfo = new ProcessStartInfo(url)
{
UseShellExecute = true
}
{
UseShellExecute = true
}
};
process.Start();
@@ -129,16 +129,34 @@ namespace NzbDrone.Common.Processes
{
foreach (DictionaryEntry environmentVariable in environmentVariables)
{
startInfo.EnvironmentVariables.Add(environmentVariable.Key.ToString(), environmentVariable.Value.ToString());
try
{
_logger.Trace("Setting environment variable '{0}' to '{1}'", environmentVariable.Key, environmentVariable.Value);
startInfo.EnvironmentVariables.Add(environmentVariable.Key.ToString(), environmentVariable.Value.ToString());
}
catch (Exception e)
{
if (environmentVariable.Value == null)
{
_logger.Error(e, "Unable to set environment variable '{0}', value is null", environmentVariable.Key);
}
else
{
_logger.Error(e, "Unable to set environment variable '{0}'", environmentVariable.Key);
}
throw;
}
}
}
logger.Debug("Starting {0} {1}", path, args);
var process = new Process
{
StartInfo = startInfo
};
{
StartInfo = startInfo
};
process.OutputDataReceived += (sender, eventArgs) =>
{
@@ -315,7 +333,7 @@ namespace NzbDrone.Common.Processes
var monoProcesses = Process.GetProcessesByName("mono")
.Union(Process.GetProcessesByName("mono-sgen"))
.Union(Process.GetProcessesByName("mono-sgen32"))
.Union(Process.GetProcessesByName("mono-sgen32"))
.Where(process =>
process.Modules.Cast<ProcessModule>()
.Any(module =>