mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-07 18:24:19 -04:00
Merge pull request #4022 from Bond-009/arraypool
Fix incorrect usage of ArrayPool
This commit is contained in:
commit
43a81366a6
@ -130,6 +130,8 @@ namespace Jellyfin.Api.Helpers
|
|||||||
private async Task<int> CopyToInternalAsync(Stream source, Stream destination, bool readAsync, CancellationToken cancellationToken)
|
private async Task<int> CopyToInternalAsync(Stream source, Stream destination, bool readAsync, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var array = ArrayPool<byte>.Shared.Rent(IODefaults.CopyToBufferSize);
|
var array = ArrayPool<byte>.Shared.Rent(IODefaults.CopyToBufferSize);
|
||||||
|
try
|
||||||
|
{
|
||||||
int bytesRead;
|
int bytesRead;
|
||||||
int totalBytesRead = 0;
|
int totalBytesRead = 0;
|
||||||
|
|
||||||
@ -171,5 +173,10 @@ namespace Jellyfin.Api.Helpers
|
|||||||
|
|
||||||
return totalBytesRead;
|
return totalBytesRead;
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
ArrayPool<byte>.Shared.Return(array);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user