From f4c202441c286202f5ee5bbae7aaeef9313198eb Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Sun, 7 Dec 2014 12:54:07 -0800 Subject: [PATCH] Cleaned up environment detection --- .../Mappers/StaticResourceMapperBase.cs | 5 ++- src/NzbDrone.Api/System/SystemModule.cs | 9 ++--- src/NzbDrone.Common/Disk/DiskProviderBase.cs | 19 ++++++--- src/NzbDrone.Common/Disk/IDiskProvider.cs | 2 +- .../EnsureThat/EnsureStringExtensions.cs | 2 +- .../EnvironmentInfo/AppFolderFactory.cs | 2 +- .../EnvironmentInfo/AppFolderInfo.cs | 2 +- src/NzbDrone.Common/EnvironmentInfo/OsInfo.cs | 11 +++--- .../Exceptron/ExceptionExtentions.cs | 2 +- .../Extensions/PathExtensions.cs | 6 +-- src/NzbDrone.Common/Http/HttpClient.cs | 8 +--- src/NzbDrone.Common/Http/UserAgentBuilder.cs | 17 ++++++++ .../Instrumentation/LogTargets.cs | 2 +- src/NzbDrone.Common/NzbDrone.Common.csproj | 1 + src/NzbDrone.Common/PathEqualityComparer.cs | 6 +-- .../Processes/PidFileProvider.cs | 23 +++++------ .../Processes/ProcessProvider.cs | 4 +- .../UpdateTests/UpdateServiceFixture.cs | 4 +- .../HealthCheck/Checks/MonoVersionCheck.cs | 2 +- .../HealthCheck/Checks/UpdateCheck.cs | 4 +- .../NotUnpackingSpecification.cs | 2 +- .../MediaFiles/MediaFileAttributeService.cs | 2 +- .../Update/InstallUpdateService.cs | 4 +- .../Update/UpdateCheckService.cs | 2 +- .../AccessControl/FirewallAdapter.cs | 2 +- src/NzbDrone.Host/ApplicationServer.cs | 2 +- src/NzbDrone.Host/Bootstrap.cs | 4 +- src/NzbDrone.Host/PlatformValidation.cs | 2 +- src/NzbDrone.Test.Common/AutoMoq/AutoMoqer.cs | 2 +- src/NzbDrone.Test.Common/NzbDroneRunner.cs | 2 +- src/NzbDrone.Test.Common/StringExtensions.cs | 2 +- src/NzbDrone.Test.Common/TestBase.cs | 5 +-- .../UpdateEngine/DetectApplicationType.cs | 2 +- .../UpdateEngine/TerminateNzbDrone.cs | 39 +++++++++---------- .../System/Info/About/AboutViewTemplate.hbs | 2 +- 35 files changed, 111 insertions(+), 94 deletions(-) create mode 100644 src/NzbDrone.Common/Http/UserAgentBuilder.cs diff --git a/src/NzbDrone.Api/Frontend/Mappers/StaticResourceMapperBase.cs b/src/NzbDrone.Api/Frontend/Mappers/StaticResourceMapperBase.cs index 1ef70d2af..c3c069ea3 100644 --- a/src/NzbDrone.Api/Frontend/Mappers/StaticResourceMapperBase.cs +++ b/src/NzbDrone.Api/Frontend/Mappers/StaticResourceMapperBase.cs @@ -1,3 +1,4 @@ +using System; using System.IO; using NLog; using Nancy; @@ -11,7 +12,7 @@ namespace NzbDrone.Api.Frontend.Mappers { private readonly IDiskProvider _diskProvider; private readonly Logger _logger; - private readonly bool _caseSensitive; + private readonly StringComparison _caseSensitive; private static readonly NotFoundResponse NotFoundResponse = new NotFoundResponse(); @@ -22,7 +23,7 @@ namespace NzbDrone.Api.Frontend.Mappers if (!RuntimeInfoBase.IsProduction) { - _caseSensitive = true; + _caseSensitive = StringComparison.OrdinalIgnoreCase; } } diff --git a/src/NzbDrone.Api/System/SystemModule.cs b/src/NzbDrone.Api/System/SystemModule.cs index e69227da3..2fe13c530 100644 --- a/src/NzbDrone.Api/System/SystemModule.cs +++ b/src/NzbDrone.Api/System/SystemModule.cs @@ -51,16 +51,16 @@ namespace NzbDrone.Api.System StartupPath = _appFolderInfo.StartUpFolder, AppData = _appFolderInfo.GetAppDataPath(), OsVersion = OsInfo.Version.ToString(), - IsMonoRuntime = OsInfo.IsMono, - IsMono = OsInfo.IsMono, - IsLinux = OsInfo.IsMono, + IsMonoRuntime = OsInfo.IsMonoRuntime, + IsMono = OsInfo.IsNotWindows, + IsLinux = OsInfo.IsLinux, IsOsx = OsInfo.IsOsx, IsWindows = OsInfo.IsWindows, Branch = _configFileProvider.Branch, Authentication = _configFileProvider.AuthenticationEnabled, SqliteVersion = _database.Version, UrlBase = _configFileProvider.UrlBase, - RuntimeVersion = OsInfo.IsMono ? _runtimeInfo.RuntimeVersion : null + RuntimeVersion = _runtimeInfo.RuntimeVersion }.AsResponse(); } @@ -82,4 +82,3 @@ namespace NzbDrone.Api.System } } } - \ No newline at end of file diff --git a/src/NzbDrone.Common/Disk/DiskProviderBase.cs b/src/NzbDrone.Common/Disk/DiskProviderBase.cs index 00e435369..b04bbc83a 100644 --- a/src/NzbDrone.Common/Disk/DiskProviderBase.cs +++ b/src/NzbDrone.Common/Disk/DiskProviderBase.cs @@ -87,19 +87,26 @@ namespace NzbDrone.Common.Disk public bool FileExists(string path) { Ensure.That(path, () => path).IsValidPath(); - return FileExists(path, OsInfo.IsMono); + return FileExists(path, OsInfo.PathStringComparison); } - public bool FileExists(string path, bool caseSensitive) + public bool FileExists(string path, StringComparison stringComparison) { Ensure.That(path, () => path).IsValidPath(); - if (caseSensitive) + switch (stringComparison) { - return File.Exists(path) && path == path.GetActualCasing(); + case StringComparison.CurrentCulture: + case StringComparison.InvariantCulture: + case StringComparison.Ordinal: + { + return File.Exists(path) && path == path.GetActualCasing(); + } + default: + { + return File.Exists(path); + } } - - return File.Exists(path); } public string[] GetDirectories(string path) diff --git a/src/NzbDrone.Common/Disk/IDiskProvider.cs b/src/NzbDrone.Common/Disk/IDiskProvider.cs index cc9934019..57817c8fa 100644 --- a/src/NzbDrone.Common/Disk/IDiskProvider.cs +++ b/src/NzbDrone.Common/Disk/IDiskProvider.cs @@ -17,7 +17,7 @@ namespace NzbDrone.Common.Disk void EnsureFolder(string path); bool FolderExists(string path); bool FileExists(string path); - bool FileExists(string path, bool caseSensitive); + bool FileExists(string path, StringComparison stringComparison); string[] GetDirectories(string path); string[] GetFiles(string path, SearchOption searchOption); long GetFolderSize(string path); diff --git a/src/NzbDrone.Common/EnsureThat/EnsureStringExtensions.cs b/src/NzbDrone.Common/EnsureThat/EnsureStringExtensions.cs index 8b8d53e89..6532dd593 100644 --- a/src/NzbDrone.Common/EnsureThat/EnsureStringExtensions.cs +++ b/src/NzbDrone.Common/EnsureThat/EnsureStringExtensions.cs @@ -101,7 +101,7 @@ namespace NzbDrone.Common.EnsureThat if (param.Value.IsPathValid()) return param; - if (OsInfo.IsMono) + if (OsInfo.IsNotWindows) { throw ExceptionFactory.CreateForParamValidation(param.Name, string.Format("value [{0}] is not a valid *nix path. paths must start with /", param.Value)); } diff --git a/src/NzbDrone.Common/EnvironmentInfo/AppFolderFactory.cs b/src/NzbDrone.Common/EnvironmentInfo/AppFolderFactory.cs index 3f470a963..55ae2319d 100644 --- a/src/NzbDrone.Common/EnvironmentInfo/AppFolderFactory.cs +++ b/src/NzbDrone.Common/EnvironmentInfo/AppFolderFactory.cs @@ -29,7 +29,7 @@ namespace NzbDrone.Common.EnvironmentInfo { _diskProvider.EnsureFolder(_appFolderInfo.AppDataFolder); - if (!OsInfo.IsMono) + if (OsInfo.IsWindows) { SetPermissions(); } diff --git a/src/NzbDrone.Common/EnvironmentInfo/AppFolderInfo.cs b/src/NzbDrone.Common/EnvironmentInfo/AppFolderInfo.cs index da1e7cfaa..a03e4173b 100644 --- a/src/NzbDrone.Common/EnvironmentInfo/AppFolderInfo.cs +++ b/src/NzbDrone.Common/EnvironmentInfo/AppFolderInfo.cs @@ -17,7 +17,7 @@ namespace NzbDrone.Common.EnvironmentInfo public AppFolderInfo(IStartupContext startupContext) { - if (OsInfo.IsMono) + if (OsInfo.IsNotWindows) { DATA_SPECIAL_FOLDER = Environment.SpecialFolder.ApplicationData; } diff --git a/src/NzbDrone.Common/EnvironmentInfo/OsInfo.cs b/src/NzbDrone.Common/EnvironmentInfo/OsInfo.cs index 314e0e044..ad1acd487 100644 --- a/src/NzbDrone.Common/EnvironmentInfo/OsInfo.cs +++ b/src/NzbDrone.Common/EnvironmentInfo/OsInfo.cs @@ -15,17 +15,16 @@ namespace NzbDrone.Common.EnvironmentInfo Version = Environment.OSVersion.Version; IsMonoRuntime = Type.GetType("Mono.Runtime") != null; - IsMono = (platform == 4) || (platform == 6) || (platform == 128); + IsNotWindows = (platform == 4) || (platform == 6) || (platform == 128); IsOsx = IsRunningOnMac(); - IsLinux = IsMono && !IsOsx; - IsWindows = !IsMono; + IsLinux = IsNotWindows && !IsOsx; + IsWindows = !IsNotWindows; FirstDayOfWeek = CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek; - if (!IsMono) + if (IsWindows) { Os = Os.Windows; - PathStringComparison = StringComparison.OrdinalIgnoreCase; } else @@ -38,7 +37,7 @@ namespace NzbDrone.Common.EnvironmentInfo public static Version Version { get; private set; } public static bool IsMonoRuntime { get; private set; } - public static bool IsMono { get; private set; } + public static bool IsNotWindows { get; private set; } public static bool IsLinux { get; private set; } public static bool IsOsx { get; private set; } public static bool IsWindows { get; private set; } diff --git a/src/NzbDrone.Common/Exceptron/ExceptionExtentions.cs b/src/NzbDrone.Common/Exceptron/ExceptionExtentions.cs index 945ceb0d0..cb3d30b90 100644 --- a/src/NzbDrone.Common/Exceptron/ExceptionExtentions.cs +++ b/src/NzbDrone.Common/Exceptron/ExceptionExtentions.cs @@ -9,7 +9,7 @@ namespace NzbDrone.Common.Exceptron public static Exception ExceptronIgnoreOnMono(this Exception exception) { - if (OsInfo.IsMono) + if (OsInfo.IsNotWindows) { exception.ExceptronIgnore(); } diff --git a/src/NzbDrone.Common/Extensions/PathExtensions.cs b/src/NzbDrone.Common/Extensions/PathExtensions.cs index cceb312fa..074a67fe3 100644 --- a/src/NzbDrone.Common/Extensions/PathExtensions.cs +++ b/src/NzbDrone.Common/Extensions/PathExtensions.cs @@ -29,7 +29,7 @@ namespace NzbDrone.Common.Extensions var info = new FileInfo(path.Trim()); - if (!OsInfo.IsMono && info.FullName.StartsWith(@"\\")) //UNC + if (OsInfo.IsWindows && info.FullName.StartsWith(@"\\")) //UNC { return info.FullName.TrimEnd('/', '\\', ' '); } @@ -96,7 +96,7 @@ namespace NzbDrone.Common.Extensions return false; } - if (OsInfo.IsMono) + if (OsInfo.IsNotWindows) { return path.StartsWith(Path.DirectorySeparatorChar.ToString()); } @@ -135,7 +135,7 @@ namespace NzbDrone.Common.Extensions public static string GetActualCasing(this string path) { - if (OsInfo.IsMono || path.StartsWith("\\")) + if (OsInfo.IsNotWindows || path.StartsWith("\\")) { return path; } diff --git a/src/NzbDrone.Common/Http/HttpClient.cs b/src/NzbDrone.Common/Http/HttpClient.cs index 28ae46c8e..f96cbb299 100644 --- a/src/NzbDrone.Common/Http/HttpClient.cs +++ b/src/NzbDrone.Common/Http/HttpClient.cs @@ -20,14 +20,10 @@ namespace NzbDrone.Common.Http public class HttpClient : IHttpClient { private readonly Logger _logger; - private readonly string _userAgent; public HttpClient(Logger logger) { _logger = logger; - _userAgent = String.Format("Sonarr/{0} ({1} {2})", - BuildInfo.Version, - OsInfo.Os, OsInfo.Version.ToString(2)); ServicePointManager.DefaultConnectionLimit = 12; } @@ -44,7 +40,7 @@ namespace NzbDrone.Common.Http webRequest.Credentials = request.NetworkCredential; webRequest.Method = request.Method.ToString(); - webRequest.UserAgent = _userAgent; + webRequest.UserAgent = UserAgentBuilder.UserAgent; webRequest.KeepAlive = false; webRequest.AllowAutoRedirect = request.AllowAutoRedirect; @@ -132,7 +128,7 @@ namespace NzbDrone.Common.Http var stopWatch = Stopwatch.StartNew(); var webClient = new GZipWebClient(); - webClient.Headers.Add(HttpRequestHeader.UserAgent, _userAgent); + webClient.Headers.Add(HttpRequestHeader.UserAgent, UserAgentBuilder.UserAgent); webClient.DownloadFile(url, fileName); stopWatch.Stop(); _logger.Debug("Downloading Completed. took {0:0}s", stopWatch.Elapsed.Seconds); diff --git a/src/NzbDrone.Common/Http/UserAgentBuilder.cs b/src/NzbDrone.Common/Http/UserAgentBuilder.cs new file mode 100644 index 000000000..bf4981994 --- /dev/null +++ b/src/NzbDrone.Common/Http/UserAgentBuilder.cs @@ -0,0 +1,17 @@ +using System; +using NzbDrone.Common.EnvironmentInfo; + +namespace NzbDrone.Common.Http +{ + public static class UserAgentBuilder + { + public static string UserAgent { get; private set; } + + static UserAgentBuilder() + { + UserAgent = String.Format("Sonarr/{0} ({1} {2}) ", + BuildInfo.Version, + OsInfo.Os, OsInfo.Version.ToString(2)); + } + } +} \ No newline at end of file diff --git a/src/NzbDrone.Common/Instrumentation/LogTargets.cs b/src/NzbDrone.Common/Instrumentation/LogTargets.cs index e44e2652b..460384443 100644 --- a/src/NzbDrone.Common/Instrumentation/LogTargets.cs +++ b/src/NzbDrone.Common/Instrumentation/LogTargets.cs @@ -31,7 +31,7 @@ namespace NzbDrone.Common.Instrumentation } else { - if (inConsole && (OsInfo.IsMono || RuntimeInfoBase.IsUserInteractive)) + if (inConsole && (OsInfo.IsNotWindows || RuntimeInfoBase.IsUserInteractive)) { RegisterConsole(); } diff --git a/src/NzbDrone.Common/NzbDrone.Common.csproj b/src/NzbDrone.Common/NzbDrone.Common.csproj index 4a5b2de4b..902d0d0b6 100644 --- a/src/NzbDrone.Common/NzbDrone.Common.csproj +++ b/src/NzbDrone.Common/NzbDrone.Common.csproj @@ -152,6 +152,7 @@ + diff --git a/src/NzbDrone.Common/PathEqualityComparer.cs b/src/NzbDrone.Common/PathEqualityComparer.cs index 547e3087d..028933795 100644 --- a/src/NzbDrone.Common/PathEqualityComparer.cs +++ b/src/NzbDrone.Common/PathEqualityComparer.cs @@ -21,12 +21,12 @@ namespace NzbDrone.Common public int GetHashCode(string obj) { - if (OsInfo.IsMono) + if (OsInfo.IsWindows) { - return obj.CleanFilePath().GetHashCode(); + return obj.CleanFilePath().ToLower().GetHashCode(); } - return obj.CleanFilePath().ToLower().GetHashCode(); + return obj.CleanFilePath().GetHashCode(); } } } diff --git a/src/NzbDrone.Common/Processes/PidFileProvider.cs b/src/NzbDrone.Common/Processes/PidFileProvider.cs index c72832a68..814a1d7f2 100644 --- a/src/NzbDrone.Common/Processes/PidFileProvider.cs +++ b/src/NzbDrone.Common/Processes/PidFileProvider.cs @@ -25,19 +25,20 @@ namespace NzbDrone.Common.Processes public void Write() { - var filename = Path.Combine(_appFolderInfo.AppDataFolder, "nzbdrone.pid"); + if (OsInfo.IsWindows) + { + return; + } - if (OsInfo.IsMono) + var filename = Path.Combine(_appFolderInfo.AppDataFolder, "nzbdrone.pid"); + try + { + File.WriteAllText(filename, _processProvider.GetCurrentProcess().Id.ToString()); + } + catch (Exception ex) { - try - { - File.WriteAllText(filename, _processProvider.GetCurrentProcess().Id.ToString()); - } - catch (Exception ex) - { - _logger.Error("Unable to write PID file: " + filename, ex); - throw; - } + _logger.Error("Unable to write PID file: " + filename, ex); + throw; } } } diff --git a/src/NzbDrone.Common/Processes/ProcessProvider.cs b/src/NzbDrone.Common/Processes/ProcessProvider.cs index a2eff8d3d..b8353902f 100644 --- a/src/NzbDrone.Common/Processes/ProcessProvider.cs +++ b/src/NzbDrone.Common/Processes/ProcessProvider.cs @@ -96,7 +96,7 @@ namespace NzbDrone.Common.Processes public Process Start(string path, string args = null, Action onOutputDataReceived = null, Action onErrorDataReceived = null) { - if (OsInfo.IsMono && path.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase)) + if (OsInfo.IsMonoRuntime && path.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase)) { args = path + " " + args; path = "mono"; @@ -155,7 +155,7 @@ namespace NzbDrone.Common.Processes public Process SpawnNewProcess(string path, string args = null) { - if (OsInfo.IsMono && path.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase)) + if (OsInfo.IsMonoRuntime && path.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase)) { args = path + " " + args; path = "mono"; diff --git a/src/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs b/src/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs index f02eecba9..6fbd83684 100644 --- a/src/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs +++ b/src/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs @@ -73,7 +73,7 @@ namespace NzbDrone.Core.Test.UpdateTests .Returns(path); Mocker.GetMock() - .Setup(s => s.FileExists(path, true)) + .Setup(s => s.FileExists(path, StringComparison.Ordinal)) .Returns(true); } @@ -208,7 +208,7 @@ namespace NzbDrone.Core.Test.UpdateTests GivenInstallScript(scriptPath); Mocker.GetMock() - .Setup(s => s.FileExists(scriptPath, true)) + .Setup(s => s.FileExists(scriptPath, StringComparison.Ordinal)) .Returns(false); Subject.Execute(new ApplicationUpdateCommand()); diff --git a/src/NzbDrone.Core/HealthCheck/Checks/MonoVersionCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/MonoVersionCheck.cs index 5a3249857..a94c5d4c6 100644 --- a/src/NzbDrone.Core/HealthCheck/Checks/MonoVersionCheck.cs +++ b/src/NzbDrone.Core/HealthCheck/Checks/MonoVersionCheck.cs @@ -21,7 +21,7 @@ namespace NzbDrone.Core.HealthCheck.Checks public override HealthCheck Check() { - if (!OsInfo.IsMono) + if (OsInfo.IsWindows) { return new HealthCheck(GetType()); } diff --git a/src/NzbDrone.Core/HealthCheck/Checks/UpdateCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/UpdateCheck.cs index 704eb2799..abeaa0137 100644 --- a/src/NzbDrone.Core/HealthCheck/Checks/UpdateCheck.cs +++ b/src/NzbDrone.Core/HealthCheck/Checks/UpdateCheck.cs @@ -24,10 +24,10 @@ namespace NzbDrone.Core.HealthCheck.Checks _checkUpdateService = checkUpdateService; _configFileProvider = configFileProvider; } - + public override HealthCheck Check() { - if (OsInfo.IsWindows || (OsInfo.IsMono && _configFileProvider.UpdateAutomatically)) + if (OsInfo.IsWindows || _configFileProvider.UpdateAutomatically) { try { diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotUnpackingSpecification.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotUnpackingSpecification.cs index b55afa761..c18f96466 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotUnpackingSpecification.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotUnpackingSpecification.cs @@ -38,7 +38,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications { if (parent.Name.StartsWith(workingFolder)) { - if (OsInfo.IsMono) + if (OsInfo.IsNotWindows) { _logger.Debug("{0} is still being unpacked", localEpisode.Path); return false; diff --git a/src/NzbDrone.Core/MediaFiles/MediaFileAttributeService.cs b/src/NzbDrone.Core/MediaFiles/MediaFileAttributeService.cs index 3e6638cfa..e6c84af26 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaFileAttributeService.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaFileAttributeService.cs @@ -60,7 +60,7 @@ namespace NzbDrone.Core.MediaFiles public void SetFolderPermissions(string path) { - if (OsInfo.IsMono) + if (OsInfo.IsNotWindows) { SetMonoPermissions(path, _configService.FolderChmod); } diff --git a/src/NzbDrone.Core/Update/InstallUpdateService.cs b/src/NzbDrone.Core/Update/InstallUpdateService.cs index 500ec778d..e450a89e2 100644 --- a/src/NzbDrone.Core/Update/InstallUpdateService.cs +++ b/src/NzbDrone.Core/Update/InstallUpdateService.cs @@ -94,7 +94,7 @@ namespace NzbDrone.Core.Update _backupService.Backup(BackupType.Update); - if (OsInfo.IsMono && _configFileProvider.UpdateMechanism == UpdateMechanism.Script) + if (OsInfo.IsNotWindows && _configFileProvider.UpdateMechanism == UpdateMechanism.Script) { InstallUpdateWithScript(updateSandboxFolder); return; @@ -124,7 +124,7 @@ namespace NzbDrone.Core.Update throw new ArgumentException("Update Script has not been defined"); } - if (!_diskProvider.FileExists(scriptPath, true)) + if (!_diskProvider.FileExists(scriptPath, StringComparison.Ordinal)) { var message = String.Format("Update Script: '{0}' does not exist", scriptPath); throw new FileNotFoundException(message, scriptPath); diff --git a/src/NzbDrone.Core/Update/UpdateCheckService.cs b/src/NzbDrone.Core/Update/UpdateCheckService.cs index 8711224bd..bbed226ac 100644 --- a/src/NzbDrone.Core/Update/UpdateCheckService.cs +++ b/src/NzbDrone.Core/Update/UpdateCheckService.cs @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Update public UpdatePackage AvailableUpdate() { - if (OsInfo.IsMono && !_configFileProvider.UpdateAutomatically) + if (OsInfo.IsNotWindows && !_configFileProvider.UpdateAutomatically) { return null; } diff --git a/src/NzbDrone.Host/AccessControl/FirewallAdapter.cs b/src/NzbDrone.Host/AccessControl/FirewallAdapter.cs index 70d9f98dc..8b398deec 100644 --- a/src/NzbDrone.Host/AccessControl/FirewallAdapter.cs +++ b/src/NzbDrone.Host/AccessControl/FirewallAdapter.cs @@ -87,7 +87,7 @@ namespace NzbDrone.Host.AccessControl private bool IsFirewallEnabled() { - if (OsInfo.IsMono) return false; + if (OsInfo.IsNotWindows) return false; try { diff --git a/src/NzbDrone.Host/ApplicationServer.cs b/src/NzbDrone.Host/ApplicationServer.cs index 4eb3cbbe6..fdd3c3683 100644 --- a/src/NzbDrone.Host/ApplicationServer.cs +++ b/src/NzbDrone.Host/ApplicationServer.cs @@ -46,7 +46,7 @@ namespace NzbDrone.Host public void Start() { - if (OsInfo.IsMono) + if (OsInfo.IsNotWindows) { Console.CancelKeyPress += (sender, eventArgs) => LogManager.Configuration = null; } diff --git a/src/NzbDrone.Host/Bootstrap.cs b/src/NzbDrone.Host/Bootstrap.cs index 53331baa5..bb33af2cd 100644 --- a/src/NzbDrone.Host/Bootstrap.cs +++ b/src/NzbDrone.Host/Bootstrap.cs @@ -108,12 +108,12 @@ namespace NzbDrone.Host return ApplicationModes.Help; } - if (!OsInfo.IsMono && startupContext.InstallService) + if (OsInfo.IsWindows && startupContext.InstallService) { return ApplicationModes.InstallService; } - if (!OsInfo.IsMono && startupContext.UninstallService) + if (OsInfo.IsWindows && startupContext.UninstallService) { return ApplicationModes.UninstallService; } diff --git a/src/NzbDrone.Host/PlatformValidation.cs b/src/NzbDrone.Host/PlatformValidation.cs index d51008a32..f11a5e7fd 100644 --- a/src/NzbDrone.Host/PlatformValidation.cs +++ b/src/NzbDrone.Host/PlatformValidation.cs @@ -15,7 +15,7 @@ namespace NzbDrone.Host public static bool IsValidate(IUserAlert userAlert) { - if (OsInfo.IsMono) + if (OsInfo.IsNotWindows) { return true; } diff --git a/src/NzbDrone.Test.Common/AutoMoq/AutoMoqer.cs b/src/NzbDrone.Test.Common/AutoMoq/AutoMoqer.cs index d9eebe47a..1796d715d 100644 --- a/src/NzbDrone.Test.Common/AutoMoq/AutoMoqer.cs +++ b/src/NzbDrone.Test.Common/AutoMoq/AutoMoqer.cs @@ -173,7 +173,7 @@ namespace NzbDrone.Test.Common.AutoMoq { var assemblyName = "NzbDrone.Windows"; - if (OsInfo.IsMono) + if (OsInfo.IsNotWindows) { assemblyName = "NzbDrone.Mono"; } diff --git a/src/NzbDrone.Test.Common/NzbDroneRunner.cs b/src/NzbDrone.Test.Common/NzbDroneRunner.cs index ab7814ec2..fdc4c9231 100644 --- a/src/NzbDrone.Test.Common/NzbDroneRunner.cs +++ b/src/NzbDrone.Test.Common/NzbDroneRunner.cs @@ -33,7 +33,7 @@ namespace NzbDrone.Test.Common var nzbdroneConsoleExe = "NzbDrone.Console.exe"; - if (OsInfo.IsMono) + if (OsInfo.IsNotWindows) { nzbdroneConsoleExe = "NzbDrone.exe"; } diff --git a/src/NzbDrone.Test.Common/StringExtensions.cs b/src/NzbDrone.Test.Common/StringExtensions.cs index 09b9b5b2d..3cdb3bf35 100644 --- a/src/NzbDrone.Test.Common/StringExtensions.cs +++ b/src/NzbDrone.Test.Common/StringExtensions.cs @@ -7,7 +7,7 @@ namespace NzbDrone.Test.Common { public static string AsOsAgnostic(this string path) { - if (OsInfo.IsMono) + if (OsInfo.IsNotWindows) { if (path.Length > 2 && path[1] == ':') { diff --git a/src/NzbDrone.Test.Common/TestBase.cs b/src/NzbDrone.Test.Common/TestBase.cs index 08e7b3451..dcaedfc98 100644 --- a/src/NzbDrone.Test.Common/TestBase.cs +++ b/src/NzbDrone.Test.Common/TestBase.cs @@ -128,16 +128,15 @@ namespace NzbDrone.Test.Common protected void WindowsOnly() { - if (OsInfo.IsMono) + if (OsInfo.IsNotWindows) { throw new IgnoreException("windows specific test"); } } - protected void MonoOnly() { - if (!OsInfo.IsMono) + if (OsInfo.IsWindows) { throw new IgnoreException("mono specific test"); } diff --git a/src/NzbDrone.Update/UpdateEngine/DetectApplicationType.cs b/src/NzbDrone.Update/UpdateEngine/DetectApplicationType.cs index aeed37c45..e7507b25d 100644 --- a/src/NzbDrone.Update/UpdateEngine/DetectApplicationType.cs +++ b/src/NzbDrone.Update/UpdateEngine/DetectApplicationType.cs @@ -22,7 +22,7 @@ namespace NzbDrone.Update.UpdateEngine public AppType GetAppType() { - if (OsInfo.IsMono) + if (OsInfo.IsNotWindows) { //Tehcnically its the console, but its been renamed for mono (Linux/OS X) return AppType.Normal; diff --git a/src/NzbDrone.Update/UpdateEngine/TerminateNzbDrone.cs b/src/NzbDrone.Update/UpdateEngine/TerminateNzbDrone.cs index 62d56b2d6..875e227a8 100644 --- a/src/NzbDrone.Update/UpdateEngine/TerminateNzbDrone.cs +++ b/src/NzbDrone.Update/UpdateEngine/TerminateNzbDrone.cs @@ -27,34 +27,31 @@ namespace NzbDrone.Update.UpdateEngine public void Terminate(int processId) { - if (OsInfo.IsMono) + if (OsInfo.IsWindows) { - _logger.Info("Stopping all instances"); - _processProvider.Kill(processId); - _processProvider.KillAll(ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME); - _processProvider.KillAll(ProcessProvider.NZB_DRONE_PROCESS_NAME); - - return; - } + _logger.Info("Stopping all running services"); - _logger.Info("Stopping all running services"); - - if (_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME) - && _serviceProvider.IsServiceRunning(ServiceProvider.NZBDRONE_SERVICE_NAME)) - { - try + if (_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME) + && _serviceProvider.IsServiceRunning(ServiceProvider.NZBDRONE_SERVICE_NAME)) { - _logger.Info("NzbDrone Service is installed and running"); - _serviceProvider.Stop(ServiceProvider.NZBDRONE_SERVICE_NAME); - } - catch (Exception e) - { - _logger.ErrorException("couldn't stop service", e); + try + { + _logger.Info("NzbDrone Service is installed and running"); + _serviceProvider.Stop(ServiceProvider.NZBDRONE_SERVICE_NAME); + } + catch (Exception e) + { + _logger.ErrorException("couldn't stop service", e); + } } } + else + { + _processProvider.Kill(processId); + } _logger.Info("Killing all running processes"); - + _processProvider.KillAll(ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME); _processProvider.KillAll(ProcessProvider.NZB_DRONE_PROCESS_NAME); } diff --git a/src/UI/System/Info/About/AboutViewTemplate.hbs b/src/UI/System/Info/About/AboutViewTemplate.hbs index 4429d6a46..d24a5016b 100644 --- a/src/UI/System/Info/About/AboutViewTemplate.hbs +++ b/src/UI/System/Info/About/AboutViewTemplate.hbs @@ -5,7 +5,7 @@
Version
{{version}}
- {{#if isMono}} + {{#if isMonoRuntime}}
Mono Version
{{runtimeVersion}}
{{/if}}