diff options
| author | crobibero <cody@robibe.ro> | 2020-11-13 09:41:18 -0700 |
|---|---|---|
| committer | crobibero <cody@robibe.ro> | 2020-11-13 09:41:18 -0700 |
| commit | 7bf320922c095b67293c05b8d2e0ed79f1db78d7 (patch) | |
| tree | 2f49f41b3c3c66d24f55d1c9faa1639dadc022f1 /Emby.Server.Implementations/AppBase/ConfigurationHelper.cs | |
| parent | d5e2369dd6ac308e518a5a36a744a1a2dac45f70 (diff) | |
Fix nullability errors in Emby.Server.Implementations
Diffstat (limited to 'Emby.Server.Implementations/AppBase/ConfigurationHelper.cs')
| -rw-r--r-- | Emby.Server.Implementations/AppBase/ConfigurationHelper.cs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs index 4c9ab33a7..e19ce5edf 100644 --- a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs +++ b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs @@ -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)) { |
