From 6643ac3ea412ea62fc067ae6b24ddfe69fd18482 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 2 Jan 2019 00:41:47 +0100 Subject: [PATCH] Clean up EnvironmentInfo --- .../EnvironmentInfo/EnvironmentInfo.cs | 32 +++---------------- Jellyfin.Server/Program.cs | 9 +----- 2 files changed, 6 insertions(+), 35 deletions(-) diff --git a/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs b/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs index 985eb71da9..03e10e7ea3 100644 --- a/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs +++ b/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs @@ -8,35 +8,13 @@ namespace Emby.Server.Implementations.EnvironmentInfo // TODO: Rework @bond public class EnvironmentInfo : IEnvironmentInfo { - private MediaBrowser.Model.System.OperatingSystem? _customOperatingSystem; - - public virtual MediaBrowser.Model.System.OperatingSystem OperatingSystem + public EnvironmentInfo(MediaBrowser.Model.System.OperatingSystem operatingSystem) { - get - { - if (_customOperatingSystem.HasValue) - { - return _customOperatingSystem.Value; - } - - switch (Environment.OSVersion.Platform) - { - case PlatformID.MacOSX: - return MediaBrowser.Model.System.OperatingSystem.OSX; - case PlatformID.Win32NT: - return MediaBrowser.Model.System.OperatingSystem.Windows; - case PlatformID.Unix: - return MediaBrowser.Model.System.OperatingSystem.Linux; - } - - return MediaBrowser.Model.System.OperatingSystem.Windows; - } - set - { - _customOperatingSystem = value; - } + OperatingSystem = operatingSystem; } + public MediaBrowser.Model.System.OperatingSystem OperatingSystem { get; private set; } + public string OperatingSystemName { get @@ -69,7 +47,7 @@ namespace Emby.Server.Implementations.EnvironmentInfo } } - public Architecture SystemArchitecture { get; set; } + public Architecture SystemArchitecture { get { return RuntimeInformation.OSArchitecture; } } public string GetEnvironmentVariable(string name) { diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index f0907fd581..0150cd5337 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -57,7 +57,7 @@ namespace Jellyfin.Server _logger.LogInformation("Jellyfin version: {Version}", version); - EnvironmentInfo environmentInfo = getEnvironmentInfo(); + EnvironmentInfo environmentInfo = new EnvironmentInfo(getOperatingSystem()); ApplicationHost.LogEnvironmentInfo(_logger, appPaths, environmentInfo); SQLitePCL.Batteries_V2.Init(); @@ -220,13 +220,6 @@ namespace Jellyfin.Server return new NullImageEncoder(); } - private static EnvironmentInfo getEnvironmentInfo() - => new EnvironmentInfo() - { - SystemArchitecture = RuntimeInformation.OSArchitecture, - OperatingSystem = getOperatingSystem() - }; - private static MediaBrowser.Model.System.OperatingSystem getOperatingSystem() { switch (Environment.OSVersion.Platform) {