Fixed: Lidarr failing to start on linux if which missing (#714)

Fix startup failure when `which` missing
This commit is contained in:
ta264 2019-04-04 15:32:58 +01:00 committed by GitHub
commit 0762805572
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -56,13 +56,22 @@ namespace NzbDrone.Core.Parser
_customerRequestBuilder = new HttpRequestBuilder(_acoustIdUrl).CreateFactory(); _customerRequestBuilder = new HttpRequestBuilder(_acoustIdUrl).CreateFactory();
// An exception here will cause Lidarr to fail to start, so catch any errors
try
{
_fpcalcPath = GetFpcalcPath(); _fpcalcPath = GetFpcalcPath();
if (_fpcalcPath.IsNotNullOrWhiteSpace()) if (_fpcalcPath.IsNotNullOrWhiteSpace())
{ {
_fpcalcVersion = GetFpcalcVersion(); _fpcalcVersion = GetFpcalcVersion();
_fpcalcArgs = GetFpcalcArgs(); _fpcalcArgs = GetFpcalcArgs();
} }
} }
catch (Exception ex)
{
_logger.Error(ex, "Somthing went wrong detecting fpcalc");
}
}
public bool IsSetup() => _fpcalcPath.IsNotNullOrWhiteSpace(); public bool IsSetup() => _fpcalcPath.IsNotNullOrWhiteSpace();
public Version FpcalcVersion() => _fpcalcVersion; public Version FpcalcVersion() => _fpcalcVersion;
@ -77,17 +86,19 @@ namespace NzbDrone.Core.Parser
// check that the command exists // check that the command exists
Process p = new Process(); Process p = new Process();
p.StartInfo.FileName = "which"; p.StartInfo.FileName = path;
p.StartInfo.Arguments = $"{path}"; p.StartInfo.Arguments = "-version";
p.StartInfo.UseShellExecute = false; p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardOutput = true;
try
{
p.Start(); p.Start();
// To avoid deadlocks, always read the output stream first and then wait. // To avoid deadlocks, always read the output stream first and then wait.
string output = p.StandardOutput.ReadToEnd(); string output = p.StandardOutput.ReadToEnd();
p.WaitForExit(1000); p.WaitForExit(1000);
}
if (p.ExitCode != 0) catch
{ {
_logger.Debug("fpcalc not found"); _logger.Debug("fpcalc not found");
return null; return null;