mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-28 04:51:54 +00:00
Use null coalescing when possible
This commit is contained in:
@@ -50,11 +50,7 @@ namespace Emby.Server.Implementations.AppBase
|
||||
// If the file didn't exist before, or if something has changed, re-save
|
||||
if (buffer == null || !newBytes.AsSpan(0, newBytesLen).SequenceEqual(buffer))
|
||||
{
|
||||
var directory = Path.GetDirectoryName(path);
|
||||
if (directory == null)
|
||||
{
|
||||
throw new ResourceNotFoundException(nameof(directory));
|
||||
}
|
||||
var directory = Path.GetDirectoryName(path) ?? throw new ResourceNotFoundException(nameof(path));
|
||||
|
||||
Directory.CreateDirectory(directory);
|
||||
// Save it after load in case we got new items
|
||||
|
||||
@@ -81,12 +81,7 @@ namespace Emby.Server.Implementations.Cryptography
|
||||
throw new CryptographicException($"Requested hash method is not supported: {hashMethod}");
|
||||
}
|
||||
|
||||
using var h = HashAlgorithm.Create(hashMethod);
|
||||
if (h == null)
|
||||
{
|
||||
throw new ResourceNotFoundException(nameof(h));
|
||||
}
|
||||
|
||||
using var h = HashAlgorithm.Create(hashMethod) ?? throw new ResourceNotFoundException(nameof(hashMethod));
|
||||
if (salt.Length == 0)
|
||||
{
|
||||
return h.ComputeHash(bytes);
|
||||
|
||||
@@ -58,12 +58,7 @@ namespace Emby.Server.Implementations.Session
|
||||
|
||||
private void OnConnectionClosed(object? sender, EventArgs e)
|
||||
{
|
||||
if (sender == null)
|
||||
{
|
||||
throw new ResourceNotFoundException(nameof(sender));
|
||||
}
|
||||
|
||||
var connection = (IWebSocketConnection)sender;
|
||||
var connection = sender as IWebSocketConnection ?? throw new ResourceNotFoundException(nameof(sender));
|
||||
_logger.LogDebug("Removing websocket from session {Session}", _session.Id);
|
||||
_sockets.Remove(connection);
|
||||
connection.Closed -= OnConnectionClosed;
|
||||
|
||||
Reference in New Issue
Block a user