diff options
| author | Claus Vium <cvium@users.noreply.github.com> | 2021-10-09 12:19:44 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-09 12:19:44 +0200 |
| commit | 115669948149b2d76604deca58955cc4eedbd474 (patch) | |
| tree | 5872d34595d66d5bd446271d12d9e2a79afa355e /Emby.Server.Implementations/AppBase/ConfigurationHelper.cs | |
| parent | 1bfe6342df2fe7c094a31737bba511f9dfd44d71 (diff) | |
| parent | 9af16fcb6c892238b734c267873b1fc137d38e66 (diff) | |
Merge pull request #6657 from Bond-009/dotnetbug
Diffstat (limited to 'Emby.Server.Implementations/AppBase/ConfigurationHelper.cs')
| -rw-r--r-- | Emby.Server.Implementations/AppBase/ConfigurationHelper.cs | 9 |
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); } } |
