diff options
| author | Bond-009 <bond.009@outlook.com> | 2020-04-25 16:02:39 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-25 16:02:39 +0200 |
| commit | f81833693d0cae476d923f704451bb794a78da8a (patch) | |
| tree | 3c3a407d5fbe5d09b05ac278b79c0bb67e6360ee /Emby.Server.Implementations/AppBase/ConfigurationHelper.cs | |
| parent | 3c366954ae123e37ea4c6e6b38b7cc0968f66071 (diff) | |
| parent | f5f990154456af149b60f7436fbdf6ac0c2281f4 (diff) | |
Merge pull request #2874 from barronpm/warnings-cleanup1
Emby.Server.Implementations code cleanup and warning fixes (Part 1)
Diffstat (limited to 'Emby.Server.Implementations/AppBase/ConfigurationHelper.cs')
| -rw-r--r-- | Emby.Server.Implementations/AppBase/ConfigurationHelper.cs | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs index 854d7b4cb..0b681fddf 100644 --- a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs +++ b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs @@ -36,24 +36,22 @@ namespace Emby.Server.Implementations.AppBase configuration = Activator.CreateInstance(type); } - using (var stream = new MemoryStream()) - { - xmlSerializer.SerializeToStream(configuration, stream); - - // Take the object we just got and serialize it back to bytes - var newBytes = stream.ToArray(); + using var stream = new MemoryStream(); + xmlSerializer.SerializeToStream(configuration, stream); - // If the file didn't exist before, or if something has changed, re-save - if (buffer == null || !buffer.SequenceEqual(newBytes)) - { - Directory.CreateDirectory(Path.GetDirectoryName(path)); + // Take the object we just got and serialize it back to bytes + var newBytes = stream.ToArray(); - // Save it after load in case we got new items - File.WriteAllBytes(path, newBytes); - } + // If the file didn't exist before, or if something has changed, re-save + if (buffer == null || !buffer.SequenceEqual(newBytes)) + { + Directory.CreateDirectory(Path.GetDirectoryName(path)); - return configuration; + // Save it after load in case we got new items + File.WriteAllBytes(path, newBytes); } + + return configuration; } } } |
