diff options
| author | Bond_009 <bond.009@outlook.com> | 2022-01-22 23:36:42 +0100 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2022-01-22 23:36:42 +0100 |
| commit | e7be01d7a5b7d2e93d8ee0fddb812c2ce048db50 (patch) | |
| tree | ab507f37a06391fbe4829586bee6e3c2e7189f17 /Jellyfin.Server/Program.cs | |
| parent | cd675475bc5f37d4b20ed71271b17d0945b3f969 (diff) | |
Flush to disk async where possible
Diffstat (limited to 'Jellyfin.Server/Program.cs')
| -rw-r--r-- | Jellyfin.Server/Program.cs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index f40526e22..2929355ec 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -545,12 +545,15 @@ namespace Jellyfin.Server // Get a stream of the resource contents // NOTE: The .csproj name is used instead of the assembly name in the resource path const string ResourcePath = "Jellyfin.Server.Resources.Configuration.logging.json"; - await using Stream resource = typeof(Program).Assembly.GetManifestResourceStream(ResourcePath) + Stream resource = typeof(Program).Assembly.GetManifestResourceStream(ResourcePath) ?? throw new InvalidOperationException($"Invalid resource path: '{ResourcePath}'"); - - // Copy the resource contents to the expected file path for the config file - await using Stream dst = new FileStream(configPath, FileMode.CreateNew, FileAccess.Write, FileShare.None, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous); - await resource.CopyToAsync(dst).ConfigureAwait(false); + Stream dst = new FileStream(configPath, FileMode.CreateNew, FileAccess.Write, FileShare.None, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous); + await using (resource.ConfigureAwait(false)) + await using (dst.ConfigureAwait(false)) + { + // Copy the resource contents to the expected file path for the config file + await resource.CopyToAsync(dst).ConfigureAwait(false); + } } /// <summary> |
