From 9e0958d8224ef3fa51893fd5a38cc57104f32422 Mon Sep 17 00:00:00 2001 From: David Ullmer Date: Wed, 18 Aug 2021 14:22:01 +0200 Subject: [PATCH] Apply suggestions from code review --- Jellyfin.Api/Controllers/ImageController.cs | 7 +++---- Jellyfin.Drawing.Skia/SplashscreenBuilder.cs | 6 ++---- MediaBrowser.Model/Branding/BrandingOptions.cs | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Jellyfin.Api/Controllers/ImageController.cs b/Jellyfin.Api/Controllers/ImageController.cs index 3b2fc98e79..24059cddd3 100644 --- a/Jellyfin.Api/Controllers/ImageController.cs +++ b/Jellyfin.Api/Controllers/ImageController.cs @@ -1803,15 +1803,14 @@ namespace Jellyfin.Api.Controllers { await using var memoryStream = await GetMemoryStream(Request.Body).ConfigureAwait(false); - // Handle image/png; charset=utf-8 - var mimeType = Request.ContentType.Split(';').FirstOrDefault(); + var mimeType = MediaTypeHeaderValue.Parse(Request.ContentType).MediaType; - if (mimeType == null) + if (!mimeType.HasValue) { return BadRequest("Error reading mimetype from uploaded image"); } - var filePath = Path.Combine(_appPaths.DataPath, "splashscreen-upload" + MimeTypes.ToExtension(mimeType)); + var filePath = Path.Combine(_appPaths.DataPath, "splashscreen-upload" + MimeTypes.ToExtension(mimeType.Value)); var brandingOptions = _serverConfigurationManager.GetConfiguration("branding"); brandingOptions.SplashscreenLocation = filePath; _serverConfigurationManager.SaveConfiguration("branding", brandingOptions); diff --git a/Jellyfin.Drawing.Skia/SplashscreenBuilder.cs b/Jellyfin.Drawing.Skia/SplashscreenBuilder.cs index 2056515549..9f801c3208 100644 --- a/Jellyfin.Drawing.Skia/SplashscreenBuilder.cs +++ b/Jellyfin.Drawing.Skia/SplashscreenBuilder.cs @@ -19,8 +19,6 @@ namespace Jellyfin.Drawing.Skia private readonly SkiaEncoder _skiaEncoder; - private Random? _random; - /// /// Initializes a new instance of the class. /// @@ -54,7 +52,7 @@ namespace Jellyfin.Drawing.Skia /// The created collage as a bitmap. private SKBitmap GenerateCollage(IReadOnlyList posters, IReadOnlyList backdrop) { - _random = new Random(); + var random = new Random(); var posterIndex = 0; var backdropIndex = 0; @@ -67,7 +65,7 @@ namespace Jellyfin.Drawing.Skia for (int i = 0; i < Rows; i++) { - int imageCounter = _random.Next(0, 5); + int imageCounter = random.Next(0, 5); int currentWidthPos = i * 75; int currentHeight = i * (posterHeight + Spacing); diff --git a/MediaBrowser.Model/Branding/BrandingOptions.cs b/MediaBrowser.Model/Branding/BrandingOptions.cs index 18a177e2db..56e5a87152 100644 --- a/MediaBrowser.Model/Branding/BrandingOptions.cs +++ b/MediaBrowser.Model/Branding/BrandingOptions.cs @@ -33,6 +33,6 @@ namespace MediaBrowser.Model.Branding /// Gets the splashscreen url. /// [XmlIgnore] - public string SplashscreenUrl => "/Branding/Splashscreen"; + public string? SplashscreenUrl => "/Branding/Splashscreen"; } }