aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/IO/StreamHelper.cs
diff options
context:
space:
mode:
authorNyanmisaka <nst799610810@gmail.com>2020-09-04 02:55:57 +0800
committerGitHub <noreply@github.com>2020-09-04 02:55:57 +0800
commit4cb0a57e4645aba8e5e65c7d086091b9161c6c09 (patch)
tree25e77817485d70cac8ec3e11a785b08b69d0c60b /Emby.Server.Implementations/IO/StreamHelper.cs
parent54349fc94597824714f623b8c31583fc044274aa (diff)
parent53703566b5e1239bbab308031d94df34a4d168aa (diff)
Merge branch 'master' into tonemap
Diffstat (limited to 'Emby.Server.Implementations/IO/StreamHelper.cs')
-rw-r--r--Emby.Server.Implementations/IO/StreamHelper.cs32
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;