Apply suggestions from code review

This commit is contained in:
David Ullmer 2021-08-18 14:22:01 +02:00 committed by Cody Robibero
parent 9e23af5636
commit 9e0958d822
3 changed files with 6 additions and 9 deletions

View File

@ -1803,15 +1803,14 @@ namespace Jellyfin.Api.Controllers
{ {
await using var memoryStream = await GetMemoryStream(Request.Body).ConfigureAwait(false); await using var memoryStream = await GetMemoryStream(Request.Body).ConfigureAwait(false);
// Handle image/png; charset=utf-8 var mimeType = MediaTypeHeaderValue.Parse(Request.ContentType).MediaType;
var mimeType = Request.ContentType.Split(';').FirstOrDefault();
if (mimeType == null) if (!mimeType.HasValue)
{ {
return BadRequest("Error reading mimetype from uploaded image"); 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<BrandingOptions>("branding"); var brandingOptions = _serverConfigurationManager.GetConfiguration<BrandingOptions>("branding");
brandingOptions.SplashscreenLocation = filePath; brandingOptions.SplashscreenLocation = filePath;
_serverConfigurationManager.SaveConfiguration("branding", brandingOptions); _serverConfigurationManager.SaveConfiguration("branding", brandingOptions);

View File

@ -19,8 +19,6 @@ namespace Jellyfin.Drawing.Skia
private readonly SkiaEncoder _skiaEncoder; private readonly SkiaEncoder _skiaEncoder;
private Random? _random;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="SplashscreenBuilder"/> class. /// Initializes a new instance of the <see cref="SplashscreenBuilder"/> class.
/// </summary> /// </summary>
@ -54,7 +52,7 @@ namespace Jellyfin.Drawing.Skia
/// <returns>The created collage as a bitmap.</returns> /// <returns>The created collage as a bitmap.</returns>
private SKBitmap GenerateCollage(IReadOnlyList<string> posters, IReadOnlyList<string> backdrop) private SKBitmap GenerateCollage(IReadOnlyList<string> posters, IReadOnlyList<string> backdrop)
{ {
_random = new Random(); var random = new Random();
var posterIndex = 0; var posterIndex = 0;
var backdropIndex = 0; var backdropIndex = 0;
@ -67,7 +65,7 @@ namespace Jellyfin.Drawing.Skia
for (int i = 0; i < Rows; i++) for (int i = 0; i < Rows; i++)
{ {
int imageCounter = _random.Next(0, 5); int imageCounter = random.Next(0, 5);
int currentWidthPos = i * 75; int currentWidthPos = i * 75;
int currentHeight = i * (posterHeight + Spacing); int currentHeight = i * (posterHeight + Spacing);

View File

@ -33,6 +33,6 @@ namespace MediaBrowser.Model.Branding
/// Gets the splashscreen url. /// Gets the splashscreen url.
/// </summary> /// </summary>
[XmlIgnore] [XmlIgnore]
public string SplashscreenUrl => "/Branding/Splashscreen"; public string? SplashscreenUrl => "/Branding/Splashscreen";
} }
} }