Applied review comments

pull/12798/head
JPVenson 2 months ago
parent 1c3196dd5f
commit a0c568bc6c

@ -72,7 +72,7 @@ public class PlaystateController : BaseJellyfinApiController
[HttpPost("UserPlayedItems/{itemId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult<UserItemDataDto>> MarkPlayedItem(
public async Task<ActionResult<UserItemDataDto?>> MarkPlayedItem(
[FromQuery] Guid? userId,
[FromRoute, Required] Guid itemId,
[FromQuery, ModelBinder(typeof(LegacyDateTimeModelBinder))] DateTime? datePlayed)
@ -121,7 +121,7 @@ public class PlaystateController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Obsolete("Kept for backwards compatibility")]
[ApiExplorerSettings(IgnoreApi = true)]
public Task<ActionResult<UserItemDataDto>> MarkPlayedItemLegacy(
public Task<ActionResult<UserItemDataDto?>> MarkPlayedItemLegacy(
[FromRoute, Required] Guid userId,
[FromRoute, Required] Guid itemId,
[FromQuery, ModelBinder(typeof(LegacyDateTimeModelBinder))] DateTime? datePlayed)
@ -138,7 +138,7 @@ public class PlaystateController : BaseJellyfinApiController
[HttpDelete("UserPlayedItems/{itemId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult<UserItemDataDto>> MarkUnplayedItem(
public async Task<ActionResult<UserItemDataDto?>> MarkUnplayedItem(
[FromQuery] Guid? userId,
[FromRoute, Required] Guid itemId)
{
@ -185,7 +185,7 @@ public class PlaystateController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Obsolete("Kept for backwards compatibility")]
[ApiExplorerSettings(IgnoreApi = true)]
public Task<ActionResult<UserItemDataDto>> MarkUnplayedItemLegacy(
public Task<ActionResult<UserItemDataDto?>> MarkUnplayedItemLegacy(
[FromRoute, Required] Guid userId,
[FromRoute, Required] Guid itemId)
=> MarkUnplayedItem(userId, itemId);
@ -502,7 +502,7 @@ public class PlaystateController : BaseJellyfinApiController
/// <param name="wasPlayed">if set to <c>true</c> [was played].</param>
/// <param name="datePlayed">The date played.</param>
/// <returns>Task.</returns>
private UserItemDataDto UpdatePlayedStatus(User user, BaseItem item, bool wasPlayed, DateTime? datePlayed)
private UserItemDataDto? UpdatePlayedStatus(User user, BaseItem item, bool wasPlayed, DateTime? datePlayed)
{
if (wasPlayed)
{
@ -513,7 +513,7 @@ public class PlaystateController : BaseJellyfinApiController
item.MarkUnplayed(user);
}
return _userDataRepository.GetUserDataDto(item, user)!;
return _userDataRepository.GetUserDataDto(item, user);
}
private PlayMethod ValidatePlayMethod(PlayMethod method, string? playSessionId)

@ -305,7 +305,7 @@ public class UserLibraryController : BaseJellyfinApiController
/// <returns>An <see cref="OkResult"/> containing the <see cref="UserItemDataDto"/>.</returns>
[HttpDelete("UserItems/{itemId}/Rating")]
[ProducesResponseType(StatusCodes.Status200OK)]
public ActionResult<UserItemDataDto> DeleteUserItemRating(
public ActionResult<UserItemDataDto?> DeleteUserItemRating(
[FromQuery] Guid? userId,
[FromRoute, Required] Guid itemId)
{
@ -338,7 +338,7 @@ public class UserLibraryController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status200OK)]
[Obsolete("Kept for backwards compatibility")]
[ApiExplorerSettings(IgnoreApi = true)]
public ActionResult<UserItemDataDto> DeleteUserItemRatingLegacy(
public ActionResult<UserItemDataDto?> DeleteUserItemRatingLegacy(
[FromRoute, Required] Guid userId,
[FromRoute, Required] Guid itemId)
=> DeleteUserItemRating(userId, itemId);
@ -353,7 +353,7 @@ public class UserLibraryController : BaseJellyfinApiController
/// <returns>An <see cref="OkResult"/> containing the <see cref="UserItemDataDto"/>.</returns>
[HttpPost("UserItems/{itemId}/Rating")]
[ProducesResponseType(StatusCodes.Status200OK)]
public ActionResult<UserItemDataDto> UpdateUserItemRating(
public ActionResult<UserItemDataDto?> UpdateUserItemRating(
[FromQuery] Guid? userId,
[FromRoute, Required] Guid itemId,
[FromQuery] bool? likes)
@ -388,7 +388,7 @@ public class UserLibraryController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status200OK)]
[Obsolete("Kept for backwards compatibility")]
[ApiExplorerSettings(IgnoreApi = true)]
public ActionResult<UserItemDataDto> UpdateUserItemRatingLegacy(
public ActionResult<UserItemDataDto?> UpdateUserItemRatingLegacy(
[FromRoute, Required] Guid userId,
[FromRoute, Required] Guid itemId,
[FromQuery] bool? likes)
@ -679,7 +679,7 @@ public class UserLibraryController : BaseJellyfinApiController
/// <param name="user">The user.</param>
/// <param name="item">The item.</param>
/// <param name="likes">if set to <c>true</c> [likes].</param>
private UserItemDataDto UpdateUserItemRatingInternal(User user, BaseItem item, bool? likes)
private UserItemDataDto? UpdateUserItemRatingInternal(User user, BaseItem item, bool? likes)
{
// Get the user data for this item
var data = _userDataRepository.GetUserData(user, item);
@ -691,6 +691,6 @@ public class UserLibraryController : BaseJellyfinApiController
_userDataRepository.SaveUserData(user, item, data, UserDataSaveReason.UpdateUserRating, CancellationToken.None);
}
return _userDataRepository.GetUserDataDto(item, user)!;
return _userDataRepository.GetUserDataDto(item, user);
}
}

@ -1,3 +1,6 @@
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CA2227 // Collection properties should be read only
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@ -5,9 +8,6 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Jellyfin.Data.Entities;
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CA2227 // Collection properties should be read only
public class BaseItemEntity
{
public required Guid Id { get; set; }

@ -1,6 +1,6 @@
#pragma warning disable CS1591
namespace Jellyfin.Data.Entities;
#pragma warning disable CS1591
public enum BaseItemExtraType
{
Unknown = 0,

@ -1,8 +1,9 @@
#pragma warning disable CA2227
using System;
using System.Collections.Generic;
namespace Jellyfin.Data.Entities;
#pragma warning disable CA2227
/// <summary>
/// Enum TrailerTypes.
@ -39,11 +40,12 @@ public class BaseItemImageInfo
/// </summary>
public int Height { get; set; }
#pragma warning disable CA1819
#pragma warning disable CA1819 // Properties should not return arrays
/// <summary>
/// Gets or Sets the blurhash.
/// </summary>
public byte[]? Blurhash { get; set; }
#pragma warning restore CA1819
/// <summary>
/// Gets or Sets the reference id to the BaseItem.

@ -10,9 +10,7 @@ public enum ItemValueType
/// <summary>
/// Artists.
/// </summary>
#pragma warning disable CA1008 // Enums should have zero value. Cannot apply here.
Artist = 0,
#pragma warning restore CA1008 // Enums should have zero value
/// <summary>
/// Album.

@ -1,9 +1,10 @@
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System;
using System.Diagnostics.CodeAnalysis;
namespace Jellyfin.Data.Entities;
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public class MediaStreamInfo
{
public required Guid ItemId { get; set; }

@ -1,8 +1,9 @@
#pragma warning disable CA2227 // Collection properties should be read only
using System;
using System.Collections.Generic;
namespace Jellyfin.Data.Entities;
#pragma warning disable CA2227 // Collection properties should be read only
/// <summary>
/// People entity.

@ -1,3 +1,9 @@
#pragma warning disable RS0030 // Do not use banned APIs
// Do not enforce that because EFCore cannot deal with cultures well.
#pragma warning disable CA1304 // Specify CultureInfo
#pragma warning disable CA1311 // Specify a culture or use an invariant version
#pragma warning disable CA1862 // Use the 'StringComparison' method overloads to perform case-insensitive string comparisons
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@ -31,14 +37,15 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using BaseItemDto = MediaBrowser.Controller.Entities.BaseItem;
using BaseItemEntity = Jellyfin.Data.Entities.BaseItemEntity;
#pragma warning disable RS0030 // Do not use banned APIs
// Do not enforce that because EFCore cannot deal with cultures well.
#pragma warning disable CA1304 // Specify CultureInfo
#pragma warning disable CA1311 // Specify a culture or use an invariant version
#pragma warning disable CA1862 // Use the 'StringComparison' method overloads to perform case-insensitive string comparisons
namespace Jellyfin.Server.Implementations.Item;
/*
All queries in this class and all other nullable enabled EFCore repository classes will make libraral use of the null-forgiving operator "!".
This is done as the code isn't actually executed client side, but only the expressions are interpretet and the compiler cannot know that.
This is your only warning/message regarding this topic.
*/
/// <summary>
/// Handles all storage logic for BaseItems.
/// </summary>
@ -1065,7 +1072,7 @@ public sealed class BaseItemRepository
ItemId = baseItemId,
Id = Guid.NewGuid(),
Path = e.Path,
Blurhash = e.BlurHash != null ? Encoding.UTF8.GetBytes(e.BlurHash) : null,
Blurhash = e.BlurHash is null ? null : Encoding.UTF8.GetBytes(e.BlurHash),
DateModified = e.DateModified,
Height = e.Height,
Width = e.Width,
@ -1079,7 +1086,7 @@ public sealed class BaseItemRepository
return new ItemImageInfo()
{
Path = appHost?.ExpandVirtualPath(e.Path) ?? e.Path,
BlurHash = e.Blurhash != null ? Encoding.UTF8.GetString(e.Blurhash) : null,
BlurHash = e.Blurhash is null ? null : Encoding.UTF8.GetString(e.Blurhash),
DateModified = e.DateModified,
Height = e.Height,
Width = e.Width,

@ -81,11 +81,11 @@ namespace MediaBrowser.Providers.MediaInfo
if (!File.Exists(path))
{
Directory.CreateDirectory(Path.GetDirectoryName(path));
#pragma warning disable CA1826
var imageStream = imageStreams.FirstOrDefault(i => (i.Comment ?? string.Empty).Contains("front", StringComparison.OrdinalIgnoreCase)) ??
imageStreams.FirstOrDefault(i => (i.Comment ?? string.Empty).Contains("cover", StringComparison.OrdinalIgnoreCase)) ??
imageStreams.FirstOrDefault();
#pragma warning restore CA1826
var imageStreamIndex = imageStream?.Index;
var tempFile = await _mediaEncoder.ExtractAudioImage(item.Path, imageStreamIndex, cancellationToken).ConfigureAwait(false);

@ -88,6 +88,7 @@ namespace MediaBrowser.Providers.MediaInfo
: TimeSpan.FromSeconds(10);
var query = new MediaStreamQuery { ItemId = item.Id, Index = item.DefaultVideoStreamIndex };
#pragma warning disable CA1826
var videoStream = _mediaSourceManager.GetMediaStreams(query).FirstOrDefault();
if (videoStream is null)
{
@ -95,7 +96,7 @@ namespace MediaBrowser.Providers.MediaInfo
query.Index = null;
videoStream = _mediaSourceManager.GetMediaStreams(query).FirstOrDefault();
}
#pragma warning restore CA1826
if (videoStream is null)
{
_logger.LogInformation("Skipping image extraction: no video stream found for {Path}.", item.Path ?? string.Empty);

Loading…
Cancel
Save