aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs
diff options
context:
space:
mode:
authorcvium <clausvium@gmail.com>2021-11-08 10:38:08 +0100
committercvium <clausvium@gmail.com>2021-11-08 10:38:08 +0100
commitf03e77a4d5fa0ca81ecb11f0ffc4c14706a6dd7d (patch)
tree06ae22d6e13ac26ab9dcb97e54591ad55654d3e1 /Emby.Server.Implementations/AppBase/ConfigurationHelper.cs
parent153e9202397f236a4a415bd033c3b398b6e6573c (diff)
parent83859a1e6d96cbb60a3b43f7537c0ab0fbdff510 (diff)
Merge branch 'master' into TVFix
Diffstat (limited to 'Emby.Server.Implementations/AppBase/ConfigurationHelper.cs')
-rw-r--r--Emby.Server.Implementations/AppBase/ConfigurationHelper.cs9
1 files changed, 4 insertions, 5 deletions
diff --git a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs
index 0308a68e4..3a916e5c0 100644
--- a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs
+++ b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs
@@ -41,20 +41,19 @@ namespace Emby.Server.Implementations.AppBase
xmlSerializer.SerializeToStream(configuration, stream);
// Take the object we just got and serialize it back to bytes
- byte[] newBytes = stream.GetBuffer();
- int newBytesLen = (int)stream.Length;
+ Span<byte> newBytes = stream.GetBuffer().AsSpan(0, (int)stream.Length);
// 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.SequenceEqual(buffer))
{
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
- // use FileShare.None as this bypasses dotnet bug dotnet/runtime#42790 .
using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None))
{
- fs.Write(newBytes, 0, newBytesLen);
+ fs.Write(newBytes);
}
}