Remove OS information from System Info (#9175)

Co-authored-by: Bond-009 <bond.009@outlook.com>
This commit is contained in:
Patrick Barron 2023-01-26 03:05:00 -05:00 committed by GitHub
parent 6b006a576d
commit 63b0132562
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 13 additions and 96 deletions

View File

@ -7,6 +7,7 @@ using System.Globalization;
using System.Linq;
using System.Net.Http;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Emby.Dlna.PlayTo;
using Emby.Dlna.Ssdp;
@ -262,7 +263,7 @@ namespace Emby.Dlna.Main
{
_publisher = new SsdpDevicePublisher(
_communicationsServer,
MediaBrowser.Common.System.OperatingSystem.Name,
Environment.OSVersion.Platform.ToString(),
Environment.OSVersion.VersionString,
_config.GetDlnaConfiguration().SendOnlyMatchedHost)
{

View File

@ -690,7 +690,7 @@ namespace Emby.Server.Implementations
logger.LogInformation("Environment Variables: {EnvVars}", relevantEnvVars);
logger.LogInformation("Arguments: {Args}", commandLineArgs);
logger.LogInformation("Operating system: {OS}", MediaBrowser.Common.System.OperatingSystem.Name);
logger.LogInformation("Operating system: {OS}", RuntimeInformation.OSDescription);
logger.LogInformation("Architecture: {Architecture}", RuntimeInformation.OSArchitecture);
logger.LogInformation("64-Bit Process: {Is64Bit}", Environment.Is64BitProcess);
logger.LogInformation("User Interactive: {IsUserInteractive}", Environment.UserInteractive);
@ -1032,14 +1032,11 @@ namespace Emby.Server.Implementations
ItemsByNamePath = ApplicationPaths.InternalMetadataPath,
InternalMetadataPath = ApplicationPaths.InternalMetadataPath,
CachePath = ApplicationPaths.CachePath,
OperatingSystem = MediaBrowser.Common.System.OperatingSystem.Id.ToString(),
OperatingSystemDisplayName = MediaBrowser.Common.System.OperatingSystem.Name,
CanLaunchWebBrowser = CanLaunchWebBrowser,
TranscodingTempPath = ConfigurationManager.GetTranscodePath(),
ServerName = FriendlyName,
LocalAddress = GetSmartApiUrl(request),
SupportsLibraryMonitor = true,
SystemArchitecture = RuntimeInformation.OSArchitecture,
PackageName = _startupOptions.PackageName
};
}
@ -1051,7 +1048,6 @@ namespace Emby.Server.Implementations
Version = ApplicationVersionString,
ProductName = ApplicationProductName,
Id = SystemId,
OperatingSystem = MediaBrowser.Common.System.OperatingSystem.Id.ToString(),
ServerName = FriendlyName,
LocalAddress = GetSmartApiUrl(request),
StartupWizardCompleted = ConfigurationManager.CommonConfiguration.IsStartupWizardCompleted

View File

@ -4,6 +4,7 @@ using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Mime;
using System.Runtime.InteropServices;
using System.Text;
using Jellyfin.Api.Middleware;
using Jellyfin.MediaEncoding.Hls.Extensions;
@ -108,7 +109,7 @@ namespace Jellyfin.Server
string.Format(
CultureInfo.InvariantCulture,
"{0}/{1} UPnP/1.0 {2}/{3}",
MediaBrowser.Common.System.OperatingSystem.Name,
Environment.OSVersion.Platform,
Environment.OSVersion,
_serverApplicationHost.Name,
_serverApplicationHost.ApplicationVersionString));

View File

@ -1,74 +0,0 @@
#pragma warning disable CS1591
using System;
using System.Runtime.InteropServices;
using System.Threading;
using MediaBrowser.Model.System;
namespace MediaBrowser.Common.System
{
public static class OperatingSystem
{
// We can't use Interlocked.CompareExchange for enums
private static int _id = int.MaxValue;
public static OperatingSystemId Id
{
get
{
if (_id == int.MaxValue)
{
Interlocked.CompareExchange(ref _id, (int)GetId(), int.MaxValue);
}
return (OperatingSystemId)_id;
}
}
public static string Name
{
get
{
switch (Id)
{
case OperatingSystemId.BSD: return "BSD";
case OperatingSystemId.Linux: return "Linux";
case OperatingSystemId.Darwin: return "macOS";
case OperatingSystemId.Windows: return "Windows";
default: throw new PlatformNotSupportedException($"Unknown OS {Id}");
}
}
}
private static OperatingSystemId GetId()
{
switch (Environment.OSVersion.Platform)
{
// On .NET Core `MacOSX` got replaced by `Unix`, this case should never be hit.
case PlatformID.MacOSX:
return OperatingSystemId.Darwin;
case PlatformID.Win32NT:
return OperatingSystemId.Windows;
case PlatformID.Unix:
default:
{
string osDescription = RuntimeInformation.OSDescription;
if (osDescription.Contains("linux", StringComparison.OrdinalIgnoreCase))
{
return OperatingSystemId.Linux;
}
else if (osDescription.Contains("darwin", StringComparison.OrdinalIgnoreCase))
{
return OperatingSystemId.Darwin;
}
else if (osDescription.Contains("bsd", StringComparison.OrdinalIgnoreCase))
{
return OperatingSystemId.BSD;
}
throw new PlatformNotSupportedException($"Can't resolve OS with description: '{osDescription}'");
}
}
}
}
}

View File

@ -1,12 +0,0 @@
#pragma warning disable CS1591
namespace MediaBrowser.Model.System
{
public enum OperatingSystemId
{
Windows,
Linux,
Darwin,
BSD
}
}

View File

@ -1,6 +1,8 @@
#nullable disable
#pragma warning disable CS1591
using System;
namespace MediaBrowser.Model.System
{
public class PublicSystemInfo
@ -32,7 +34,8 @@ namespace MediaBrowser.Model.System
/// Gets or sets the operating system.
/// </summary>
/// <value>The operating system.</value>
public string OperatingSystem { get; set; }
[Obsolete("This is no longer set")]
public string OperatingSystem { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the id.

View File

@ -42,7 +42,8 @@ namespace MediaBrowser.Model.System
/// Gets or sets the display name of the operating system.
/// </summary>
/// <value>The display name of the operating system.</value>
public string OperatingSystemDisplayName { get; set; }
[Obsolete("This is no longer set")]
public string OperatingSystemDisplayName { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the package name.
@ -137,6 +138,7 @@ namespace MediaBrowser.Model.System
[Obsolete("This isn't set correctly anymore")]
public FFmpegLocation EncoderLocation { get; set; }
public Architecture SystemArchitecture { get; set; }
[Obsolete("This is no longer set")]
public Architecture SystemArchitecture { get; set; } = Architecture.X64;
}
}