Minor cleanup

This commit is contained in:
Bond_009 2022-08-12 20:37:31 +02:00
parent 63d943aab9
commit 5036afd691
12 changed files with 39 additions and 60 deletions

View file

@ -365,11 +365,7 @@ namespace Emby.Server.Implementations.AppBase
validatingStore.Validate(currentConfiguration, configuration); validatingStore.Validate(currentConfiguration, configuration);
} }
NamedConfigurationUpdating?.Invoke(this, new ConfigurationUpdateEventArgs NamedConfigurationUpdating?.Invoke(this, new ConfigurationUpdateEventArgs(key, configuration));
{
Key = key,
NewConfiguration = configuration
});
_configurations.AddOrUpdate(key, configuration, (_, _) => configuration); _configurations.AddOrUpdate(key, configuration, (_, _) => configuration);
@ -391,11 +387,7 @@ namespace Emby.Server.Implementations.AppBase
/// <param name="configuration">The old configuration.</param> /// <param name="configuration">The old configuration.</param>
protected virtual void OnNamedConfigurationUpdated(string key, object configuration) protected virtual void OnNamedConfigurationUpdated(string key, object configuration)
{ {
NamedConfigurationUpdated?.Invoke(this, new ConfigurationUpdateEventArgs NamedConfigurationUpdated?.Invoke(this, new ConfigurationUpdateEventArgs(key, configuration));
{
Key = key,
NewConfiguration = configuration
});
} }
/// <inheritdoc /> /// <inheritdoc />

View file

@ -25,11 +25,6 @@ namespace Jellyfin.Api.Attributes
/// <param name="template">The route template. May not be null.</param> /// <param name="template">The route template. May not be null.</param>
public HttpSubscribeAttribute(string template) public HttpSubscribeAttribute(string template)
: base(_supportedMethods, template) : base(_supportedMethods, template)
{ => ArgumentNullException.ThrowIfNull(template, nameof(template));
if (template == null)
{
throw new ArgumentNullException(nameof(template));
}
}
} }
} }

View file

@ -25,11 +25,6 @@ namespace Jellyfin.Api.Attributes
/// <param name="template">The route template. May not be null.</param> /// <param name="template">The route template. May not be null.</param>
public HttpUnsubscribeAttribute(string template) public HttpUnsubscribeAttribute(string template)
: base(_supportedMethods, template) : base(_supportedMethods, template)
{ => ArgumentNullException.ThrowIfNull(template, nameof(template));
if (template == null)
{
throw new ArgumentNullException(nameof(template));
}
}
} }
} }

View file

@ -89,12 +89,9 @@ namespace Jellyfin.Api.Controllers
// Load all custom display preferences // Load all custom display preferences
var customDisplayPreferences = _displayPreferencesManager.ListCustomItemDisplayPreferences(displayPreferences.UserId, itemId, displayPreferences.Client); var customDisplayPreferences = _displayPreferencesManager.ListCustomItemDisplayPreferences(displayPreferences.UserId, itemId, displayPreferences.Client);
if (customDisplayPreferences != null) foreach (var (key, value) in customDisplayPreferences)
{ {
foreach (var (key, value) in customDisplayPreferences) dto.CustomPrefs.TryAdd(key, value);
{
dto.CustomPrefs.TryAdd(key, value);
}
} }
// This will essentially be a noop if no changes have been made, but new prefs must be saved at least. // This will essentially be a noop if no changes have been made, but new prefs must be saved at least.

View file

@ -145,9 +145,11 @@ namespace Jellyfin.Drawing.Skia
/// <exception cref="SkiaCodecException">The file at the specified path could not be used to generate a codec.</exception> /// <exception cref="SkiaCodecException">The file at the specified path could not be used to generate a codec.</exception>
public string GetImageBlurHash(int xComp, int yComp, string path) public string GetImageBlurHash(int xComp, int yComp, string path)
{ {
if (path == null) ArgumentNullException.ThrowIfNull(path, nameof(path));
if (path.Length == 0)
{ {
throw new ArgumentNullException(nameof(path)); throw new ArgumentException("String can't be empty", nameof(path));
} }
var extension = Path.GetExtension(path.AsSpan()).TrimStart('.'); var extension = Path.GetExtension(path.AsSpan()).TrimStart('.');

View file

@ -79,7 +79,7 @@ namespace Jellyfin.Server.Implementations.Users
} }
/// <inheritdoc /> /// <inheritdoc />
public void SetCustomItemDisplayPreferences(Guid userId, Guid itemId, string client, Dictionary<string, string> customPreferences) public void SetCustomItemDisplayPreferences(Guid userId, Guid itemId, string client, Dictionary<string, string?> customPreferences)
{ {
var existingPrefs = _dbContext.CustomItemDisplayPreferences var existingPrefs = _dbContext.CustomItemDisplayPreferences
.AsQueryable() .AsQueryable()

View file

@ -69,15 +69,8 @@ namespace Jellyfin.Server.Infrastructure
/// <inheritdoc /> /// <inheritdoc />
protected override Task WriteFileAsync(ActionContext context, PhysicalFileResult result, RangeItemHeaderValue? range, long rangeLength) protected override Task WriteFileAsync(ActionContext context, PhysicalFileResult result, RangeItemHeaderValue? range, long rangeLength)
{ {
if (context == null) ArgumentNullException.ThrowIfNull(context, nameof(context));
{ ArgumentNullException.ThrowIfNull(result, nameof(result));
throw new ArgumentNullException(nameof(context));
}
if (result == null)
{
throw new ArgumentNullException(nameof(result));
}
if (range != null && rangeLength == 0) if (range != null && rangeLength == 0)
{ {

View file

@ -1,22 +1,33 @@
#nullable disable
#pragma warning disable CS1591
using System; using System;
namespace MediaBrowser.Common.Configuration namespace MediaBrowser.Common.Configuration
{ {
/// <summary>
/// <see cref="EventArgs" /> for the ConfigurationUpdated event.
/// </summary>
public class ConfigurationUpdateEventArgs : EventArgs public class ConfigurationUpdateEventArgs : EventArgs
{ {
/// <summary> /// <summary>
/// Gets or sets the key. /// Initializes a new instance of the <see cref="ConfigurationUpdateEventArgs"/> class.
/// </summary> /// </summary>
/// <value>The key.</value> /// <param name="key">The configuration key.</param>
public string Key { get; set; } /// <param name="newConfiguration">The new configuration.</param>
public ConfigurationUpdateEventArgs(string key, object newConfiguration)
{
Key = key;
NewConfiguration = newConfiguration;
}
/// <summary> /// <summary>
/// Gets or sets the new configuration. /// Gets the key.
/// </summary>
/// <value>The key.</value>
public string Key { get; }
/// <summary>
/// Gets the new configuration.
/// </summary> /// </summary>
/// <value>The new configuration.</value> /// <value>The new configuration.</value>
public object NewConfiguration { get; set; } public object NewConfiguration { get; }
} }
} }

View file

@ -1,5 +1,3 @@
#nullable disable
namespace MediaBrowser.Common.Configuration namespace MediaBrowser.Common.Configuration
{ {
/// <summary> /// <summary>

View file

@ -1,5 +1,3 @@
#nullable disable
#pragma warning disable CS1591 #pragma warning disable CS1591
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
@ -13,7 +11,7 @@ namespace MediaBrowser.Controller.Entities
public abstract class BasePluginFolder : Folder, ICollectionFolder public abstract class BasePluginFolder : Folder, ICollectionFolder
{ {
[JsonIgnore] [JsonIgnore]
public virtual string CollectionType => null; public virtual string? CollectionType => null;
[JsonIgnore] [JsonIgnore]
public override bool SupportsInheritedParentImages => false; public override bool SupportsInheritedParentImages => false;

View file

@ -1,5 +1,3 @@
#nullable disable
using System; using System;
using System.Linq; using System.Linq;
using Jellyfin.Extensions; using Jellyfin.Extensions;
@ -19,9 +17,11 @@ namespace MediaBrowser.Controller.Entities
/// <param name="url">Trailer URL.</param> /// <param name="url">Trailer URL.</param>
public static void AddTrailerUrl(this BaseItem item, string url) public static void AddTrailerUrl(this BaseItem item, string url)
{ {
if (string.IsNullOrEmpty(url)) ArgumentNullException.ThrowIfNull(url, nameof(url));
if (url.Length == 0)
{ {
throw new ArgumentNullException(nameof(url)); throw new ArgumentException("String can't be empty", nameof(url));
} }
var current = item.RemoteTrailers.FirstOrDefault(i => string.Equals(i.Url, url, StringComparison.OrdinalIgnoreCase)); var current = item.RemoteTrailers.FirstOrDefault(i => string.Equals(i.Url, url, StringComparison.OrdinalIgnoreCase));

View file

@ -1,5 +1,3 @@
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Jellyfin.Data.Entities; using Jellyfin.Data.Entities;
@ -50,7 +48,7 @@ namespace MediaBrowser.Controller
/// <param name="itemId">The item id.</param> /// <param name="itemId">The item id.</param>
/// <param name="client">The client string.</param> /// <param name="client">The client string.</param>
/// <returns>The dictionary of custom item display preferences.</returns> /// <returns>The dictionary of custom item display preferences.</returns>
Dictionary<string, string> ListCustomItemDisplayPreferences(Guid userId, Guid itemId, string client); Dictionary<string, string?> ListCustomItemDisplayPreferences(Guid userId, Guid itemId, string client);
/// <summary> /// <summary>
/// Sets the custom item display preference for the user and client. /// Sets the custom item display preference for the user and client.
@ -59,7 +57,7 @@ namespace MediaBrowser.Controller
/// <param name="itemId">The item id.</param> /// <param name="itemId">The item id.</param>
/// <param name="client">The client id.</param> /// <param name="client">The client id.</param>
/// <param name="customPreferences">A dictionary of custom item display preferences.</param> /// <param name="customPreferences">A dictionary of custom item display preferences.</param>
void SetCustomItemDisplayPreferences(Guid userId, Guid itemId, string client, Dictionary<string, string> customPreferences); void SetCustomItemDisplayPreferences(Guid userId, Guid itemId, string client, Dictionary<string, string?> customPreferences);
/// <summary> /// <summary>
/// Saves changes made to the database. /// Saves changes made to the database.