diff options
| author | Joshua M. Boniface <joshua@boniface.me> | 2020-09-03 14:40:29 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-03 14:40:29 -0400 |
| commit | 52aea85e7fa5b3e3eef965b434b79829ccecde46 (patch) | |
| tree | 912730228c1efe3b6cdb19bc8be594f5302ab84a /Emby.Server.Implementations/IO/StreamHelper.cs | |
| parent | 9cbc016b0a1f93779d6503aba0298e5bda897ea2 (diff) | |
| parent | e653eef44ff5dd7e568816d43b9e0d50b2293387 (diff) | |
Merge pull request #4031 from Bond-009/warn28
Fix some warnings
Diffstat (limited to 'Emby.Server.Implementations/IO/StreamHelper.cs')
| -rw-r--r-- | Emby.Server.Implementations/IO/StreamHelper.cs | 32 |
1 files changed, 1 insertions, 31 deletions
diff --git a/Emby.Server.Implementations/IO/StreamHelper.cs b/Emby.Server.Implementations/IO/StreamHelper.cs index 40b397edc..c16ebd61b 100644 --- a/Emby.Server.Implementations/IO/StreamHelper.cs +++ b/Emby.Server.Implementations/IO/StreamHelper.cs @@ -11,8 +11,6 @@ namespace Emby.Server.Implementations.IO { public class StreamHelper : IStreamHelper { - private const int StreamCopyToBufferSize = 81920; - public async Task CopyToAsync(Stream source, Stream destination, int bufferSize, Action onStarted, CancellationToken cancellationToken) { byte[] buffer = ArrayPool<byte>.Shared.Rent(bufferSize); @@ -83,37 +81,9 @@ namespace Emby.Server.Implementations.IO } } - public async Task<int> CopyToAsync(Stream source, Stream destination, CancellationToken cancellationToken) - { - byte[] buffer = ArrayPool<byte>.Shared.Rent(StreamCopyToBufferSize); - try - { - int totalBytesRead = 0; - - int bytesRead; - while ((bytesRead = await source.ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false)) != 0) - { - var bytesToWrite = bytesRead; - - if (bytesToWrite > 0) - { - await destination.WriteAsync(buffer, 0, Convert.ToInt32(bytesToWrite), cancellationToken).ConfigureAwait(false); - - totalBytesRead += bytesRead; - } - } - - return totalBytesRead; - } - finally - { - ArrayPool<byte>.Shared.Return(buffer); - } - } - public async Task CopyToAsync(Stream source, Stream destination, long copyLength, CancellationToken cancellationToken) { - byte[] buffer = ArrayPool<byte>.Shared.Rent(StreamCopyToBufferSize); + byte[] buffer = ArrayPool<byte>.Shared.Rent(IODefaults.CopyToBufferSize); try { int bytesRead; |
