diff options
| author | Joshua M. Boniface <joshua@boniface.me> | 2020-11-27 09:46:18 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-27 09:46:18 -0500 |
| commit | c98c2ab955230358d00fbc64ebeddeec300e88d0 (patch) | |
| tree | 9e3084b4b8eed37a5b82c6d97c729ea6f53ae40b /Emby.Server.Implementations/AppBase/ConfigurationHelper.cs | |
| parent | 9c20701cf62a7a39235b0b4d4471297770432670 (diff) | |
| parent | 9169a28df195b999c3813f842780dd7763bbcc9f (diff) | |
Merge branch 'master' into syncplay-enhanced
Diffstat (limited to 'Emby.Server.Implementations/AppBase/ConfigurationHelper.cs')
| -rw-r--r-- | Emby.Server.Implementations/AppBase/ConfigurationHelper.cs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs index 4c9ab33a7..77819c764 100644 --- a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs +++ b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs @@ -3,6 +3,7 @@ using System; using System.IO; using System.Linq; +using MediaBrowser.Common.Extensions; using MediaBrowser.Model.Serialization; namespace Emby.Server.Implementations.AppBase @@ -35,7 +36,7 @@ namespace Emby.Server.Implementations.AppBase } catch (Exception) { - configuration = Activator.CreateInstance(type); + configuration = Activator.CreateInstance(type) ?? throw new ArgumentException($"Provided path ({type}) is not valid.", nameof(type)); } using var stream = new MemoryStream(buffer?.Length ?? 0); @@ -48,8 +49,9 @@ 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) ?? throw new ArgumentException($"Provided path ({path}) is not valid.", nameof(path)); + 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)) { |
