Use ConfigureAwait in SharedHttpStream

This commit is contained in:
Patrick Barron 2023-12-05 12:28:17 -05:00
parent 4ec32b71f5
commit 3ecd68d832

View File

@ -83,14 +83,27 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
Logger.LogInformation("Beginning {StreamType} stream to {FilePath}", GetType().Name, TempFilePath); Logger.LogInformation("Beginning {StreamType} stream to {FilePath}", GetType().Name, TempFilePath);
using (response) using (response)
{ {
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false); var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
await using var fileStream = new FileStream(TempFilePath, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous); await using (stream.ConfigureAwait(false))
await StreamHelper.CopyToAsync( {
stream, var fileStream = new FileStream(
fileStream, TempFilePath,
IODefaults.CopyToBufferSize, FileMode.Create,
() => Resolve(openTaskCompletionSource), FileAccess.Write,
cancellationToken).ConfigureAwait(false); FileShare.Read,
IODefaults.FileStreamBufferSize,
FileOptions.Asynchronous);
await using (fileStream.ConfigureAwait(false))
{
await StreamHelper.CopyToAsync(
stream,
fileStream,
IODefaults.CopyToBufferSize,
() => Resolve(openTaskCompletionSource),
cancellationToken).ConfigureAwait(false);
}
}
} }
} }
catch (OperationCanceledException ex) catch (OperationCanceledException ex)