Fix nullability errors in Emby.Server.Implementations

This commit is contained in:
crobibero
2020-11-13 09:41:18 -07:00
parent d5e2369dd6
commit 7bf320922c
3 changed files with 19 additions and 3 deletions

View File

@@ -35,7 +35,8 @@ namespace Emby.Server.Implementations.AppBase
}
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);
@@ -48,8 +49,13 @@ 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))
{
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
using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read))
{