From 661ba9721556ccd374654418d09804161b8d1977 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sat, 14 Sep 2013 17:17:45 -0700 Subject: [PATCH] added folder logging to isproduction test. better process name detection in mono. --- NzbDrone.Common.Test/EnvironmentProviderTest.cs | 2 +- NzbDrone.Common/ProcessProvider.cs | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/NzbDrone.Common.Test/EnvironmentProviderTest.cs b/NzbDrone.Common.Test/EnvironmentProviderTest.cs index 8dfaf87b5..588fb06ad 100644 --- a/NzbDrone.Common.Test/EnvironmentProviderTest.cs +++ b/NzbDrone.Common.Test/EnvironmentProviderTest.cs @@ -29,7 +29,7 @@ namespace NzbDrone.Common.Test [Test] public void IsProduction_should_return_false_when_run_within_nunit() { - RuntimeInfo.IsProduction.Should().BeFalse("Process name is " + Process.GetCurrentProcess().ProcessName); + RuntimeInfo.IsProduction.Should().BeFalse("Process name is " + Process.GetCurrentProcess().ProcessName + " Folder is " + Directory.GetCurrentDirectory()); } [Test] diff --git a/NzbDrone.Common/ProcessProvider.cs b/NzbDrone.Common/ProcessProvider.cs index ffb647709..e93edd781 100644 --- a/NzbDrone.Common/ProcessProvider.cs +++ b/NzbDrone.Common/ProcessProvider.cs @@ -27,7 +27,7 @@ namespace NzbDrone.Common public class ProcessProvider : IProcessProvider { - private static readonly Logger Logger = NzbDroneLogger.GetLogger(); + private static readonly Logger Logger = NzbDroneLogger.GetLogger(); public const string NZB_DRONE_PROCESS_NAME = "NzbDrone"; public const string NZB_DRONE_CONSOLE_PROCESS_NAME = "NzbDrone.Console"; @@ -213,7 +213,7 @@ namespace NzbDrone.Common return new ProcessInfo { Id = process.Id, - StartPath = process.MainModule.FileName, + StartPath = GetExeFileName(process), Name = process.ProcessName }; } @@ -225,6 +225,17 @@ namespace NzbDrone.Common return null; } + + private static string GetExeFileName(Process process) + { + if (process.MainModule.FileName != "mono.exe") + { + return process.MainModule.FileName; + } + + return process.Modules.Cast().FirstOrDefault(module => module.ModuleName.ToLower().EndsWith(".exe")).FileName; + } + private void Kill(int processId) { var process = Process.GetProcesses().FirstOrDefault(p => p.Id == processId);