diff options
| -rw-r--r-- | Emby.Dlna/Main/DlnaEntryPoint.cs | 3 | ||||
| -rw-r--r-- | Emby.Server.Implementations/ApplicationHost.cs | 6 | ||||
| -rw-r--r-- | Jellyfin.Server/Startup.cs | 3 | ||||
| -rw-r--r-- | MediaBrowser.Common/System/OperatingSystem.cs | 74 | ||||
| -rw-r--r-- | MediaBrowser.Model/System/OperatingSystemId.cs | 12 | ||||
| -rw-r--r-- | MediaBrowser.Model/System/PublicSystemInfo.cs | 5 | ||||
| -rw-r--r-- | MediaBrowser.Model/System/SystemInfo.cs | 6 | ||||
| -rw-r--r-- | src/Jellyfin.Extensions/AlphanumericComparator.cs | 43 | ||||
| -rw-r--r-- | tests/Jellyfin.Extensions.Tests/AlphanumericComparatorTests.cs | 5 |
9 files changed, 22 insertions, 135 deletions
diff --git a/Emby.Dlna/Main/DlnaEntryPoint.cs b/Emby.Dlna/Main/DlnaEntryPoint.cs index 2dc079254..aab475153 100644 --- a/Emby.Dlna/Main/DlnaEntryPoint.cs +++ b/Emby.Dlna/Main/DlnaEntryPoint.cs @@ -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) { diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index fe1f4defe..560ba7d10 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -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 diff --git a/Jellyfin.Server/Startup.cs b/Jellyfin.Server/Startup.cs index 7abd2fbef..155f9fc8c 100644 --- a/Jellyfin.Server/Startup.cs +++ b/Jellyfin.Server/Startup.cs @@ -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)); diff --git a/MediaBrowser.Common/System/OperatingSystem.cs b/MediaBrowser.Common/System/OperatingSystem.cs deleted file mode 100644 index 5f673d320..000000000 --- a/MediaBrowser.Common/System/OperatingSystem.cs +++ /dev/null @@ -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}'"); - } - } - } - } -} diff --git a/MediaBrowser.Model/System/OperatingSystemId.cs b/MediaBrowser.Model/System/OperatingSystemId.cs deleted file mode 100644 index 2e417f6b5..000000000 --- a/MediaBrowser.Model/System/OperatingSystemId.cs +++ /dev/null @@ -1,12 +0,0 @@ -#pragma warning disable CS1591 - -namespace MediaBrowser.Model.System -{ - public enum OperatingSystemId - { - Windows, - Linux, - Darwin, - BSD - } -} diff --git a/MediaBrowser.Model/System/PublicSystemInfo.cs b/MediaBrowser.Model/System/PublicSystemInfo.cs index 53030843a..31a895642 100644 --- a/MediaBrowser.Model/System/PublicSystemInfo.cs +++ b/MediaBrowser.Model/System/PublicSystemInfo.cs @@ -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. diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.cs index 9e56849c7..bd0099af7 100644 --- a/MediaBrowser.Model/System/SystemInfo.cs +++ b/MediaBrowser.Model/System/SystemInfo.cs @@ -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; } } diff --git a/src/Jellyfin.Extensions/AlphanumericComparator.cs b/src/Jellyfin.Extensions/AlphanumericComparator.cs index 1b19752bb..6e451d40e 100644 --- a/src/Jellyfin.Extensions/AlphanumericComparator.cs +++ b/src/Jellyfin.Extensions/AlphanumericComparator.cs @@ -86,47 +86,12 @@ namespace Jellyfin.Extensions { return 1; } - else if (span1Len >= 20) // Number is probably too big for a ulong - { - // Trim all the first digits that are the same - int i = 0; - while (i < span1Len && span1[i] == span2[i]) - { - i++; - } - - // If there are no more digits it's the same number - if (i == span1Len) - { - continue; - } - - // Only need to compare the most significant digit - span1 = span1.Slice(i, 1); - span2 = span2.Slice(i, 1); - } - - if (!ulong.TryParse(span1, out var num1) - || !ulong.TryParse(span2, out var num2)) - { - return 0; - } - else if (num1 < num2) - { - return -1; - } - else if (num1 > num2) - { - return 1; - } } - else + + int result = span1.CompareTo(span2, StringComparison.InvariantCulture); + if (result != 0) { - int result = span1.CompareTo(span2, StringComparison.InvariantCulture); - if (result != 0) - { - return result; - } + return result; } } while (pos1 < len1 && pos2 < len2); diff --git a/tests/Jellyfin.Extensions.Tests/AlphanumericComparatorTests.cs b/tests/Jellyfin.Extensions.Tests/AlphanumericComparatorTests.cs index 2a7e8fafd..105e2a52a 100644 --- a/tests/Jellyfin.Extensions.Tests/AlphanumericComparatorTests.cs +++ b/tests/Jellyfin.Extensions.Tests/AlphanumericComparatorTests.cs @@ -19,6 +19,11 @@ namespace Jellyfin.Extensions.Tests [InlineData("12345678912345678912345678913234567891", "12345678912345678912345678913234567892")] [InlineData("12345678912345678912345678913234567891a", "12345678912345678912345678913234567891a")] [InlineData("12345678912345678912345678913234567891a", "12345678912345678912345678913234567891b")] + [InlineData("a5", "a11")] + [InlineData("a05a", "a5b")] + [InlineData("a5a", "a05b")] + [InlineData("6xxx", "007asdf")] + [InlineData("00042Q", "42s")] public void AlphanumericComparatorTest(params string?[] strings) { var copy = strings.Reverse().ToArray(); |
