Fix nullability errors in Emby.Server.Implementations
This commit is contained in:
parent
d5e2369dd6
commit
7bf320922c
|
@ -35,7 +35,8 @@ namespace Emby.Server.Implementations.AppBase
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
configuration = Activator.CreateInstance(type);
|
var instanceConfiguration = Activator.CreateInstance(type);
|
||||||
|
configuration = instanceConfiguration ?? throw new NullReferenceException(nameof(instanceConfiguration));
|
||||||
}
|
}
|
||||||
|
|
||||||
using var stream = new MemoryStream(buffer?.Length ?? 0);
|
using var stream = new MemoryStream(buffer?.Length ?? 0);
|
||||||
|
@ -48,8 +49,13 @@ namespace Emby.Server.Implementations.AppBase
|
||||||
// If the file didn't exist before, or if something has changed, re-save
|
// If the file didn't exist before, or if something has changed, re-save
|
||||||
if (buffer == null || !newBytes.AsSpan(0, newBytesLen).SequenceEqual(buffer))
|
if (buffer == null || !newBytes.AsSpan(0, newBytesLen).SequenceEqual(buffer))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
var directory = Path.GetDirectoryName(path);
|
||||||
|
if (directory == null)
|
||||||
|
{
|
||||||
|
throw new NullReferenceException(nameof(directory));
|
||||||
|
}
|
||||||
|
|
||||||
|
Directory.CreateDirectory(directory);
|
||||||
// Save it after load in case we got new items
|
// Save it after load in case we got new items
|
||||||
using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read))
|
using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||||
{
|
{
|
||||||
|
|
|
@ -81,6 +81,11 @@ namespace Emby.Server.Implementations.Cryptography
|
||||||
}
|
}
|
||||||
|
|
||||||
using var h = HashAlgorithm.Create(hashMethod);
|
using var h = HashAlgorithm.Create(hashMethod);
|
||||||
|
if (h == null)
|
||||||
|
{
|
||||||
|
throw new NullReferenceException(nameof(h));
|
||||||
|
}
|
||||||
|
|
||||||
if (salt.Length == 0)
|
if (salt.Length == 0)
|
||||||
{
|
{
|
||||||
return h.ComputeHash(bytes);
|
return h.ComputeHash(bytes);
|
||||||
|
|
|
@ -55,8 +55,13 @@ namespace Emby.Server.Implementations.Session
|
||||||
connection.Closed += OnConnectionClosed;
|
connection.Closed += OnConnectionClosed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnConnectionClosed(object sender, EventArgs e)
|
private void OnConnectionClosed(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (sender == null)
|
||||||
|
{
|
||||||
|
throw new NullReferenceException(nameof(sender));
|
||||||
|
}
|
||||||
|
|
||||||
var connection = (IWebSocketConnection)sender;
|
var connection = (IWebSocketConnection)sender;
|
||||||
_logger.LogDebug("Removing websocket from session {Session}", _session.Id);
|
_logger.LogDebug("Removing websocket from session {Session}", _session.Id);
|
||||||
_sockets.Remove(connection);
|
_sockets.Remove(connection);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user