diff options
| author | Bond_009 <bond.009@outlook.com> | 2020-11-17 19:43:00 +0100 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2020-11-17 19:43:00 +0100 |
| commit | 4b1c9dc9eaa120a30a7820257a83dd5aa3ecd9f4 (patch) | |
| tree | ec02efd490c0b2f354990b5aec90887ce5e9b29a /Emby.Server.Implementations/LiveTv/EmbyTV | |
| parent | 08c2c86bc7debb306f492858ca6c7b3172300bd0 (diff) | |
Pass cancellation where possible
Diffstat (limited to 'Emby.Server.Implementations/LiveTv/EmbyTV')
| -rw-r--r-- | Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs index 44560d1e21..341194f239 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs @@ -77,11 +77,12 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV _logger.LogInformation("Copying recording stream to file {0}", targetFile); // The media source if infinite so we need to handle stopping ourselves - var durationToken = new CancellationTokenSource(duration); - cancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, durationToken.Token).Token; + using var durationToken = new CancellationTokenSource(duration); + using var linkedCancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, durationToken.Token); + cancellationToken = linkedCancellationToken.Token; await _streamHelper.CopyUntilCancelled( - await response.Content.ReadAsStreamAsync().ConfigureAwait(false), + await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false), output, IODefaults.CopyToBufferSize, cancellationToken).ConfigureAwait(false); |
