Skip to content

Commit b790eeb

Browse files
author
krivchenko-kv
committed
~ S3Upload c-tor
1 parent f2246a4 commit b790eeb

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

src/Storage/S3BucketClient.Multipart.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ private async Task<S3Upload> MultipartStart(string fileName, string contentType,
172172
await responseStream.DisposeAsync().ConfigureAwait(false);
173173
response.Dispose();
174174

175-
return new S3Upload(this, fileName, encodedFileName, uploadId, ArrayPool);
175+
return new S3Upload(this, fileName, encodedFileName, uploadId);
176176
}
177177

178178
Errors.UnexpectedResult(response);

src/Storage/S3Upload.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Storage;
77
/// </summary>
88
public sealed class S3Upload : IDisposable
99
{
10-
private readonly IArrayPool _arrayPool;
10+
1111
private readonly S3BucketClient _client;
1212
private readonly string _encodedFileName;
1313

@@ -16,16 +16,15 @@ public sealed class S3Upload : IDisposable
1616
private int _partCount;
1717
private string[] _parts;
1818

19-
internal S3Upload(S3BucketClient client, string fileName, string encodedFileName, string uploadId, IArrayPool arrayPool)
19+
internal S3Upload(S3BucketClient client, string fileName, string encodedFileName, string uploadId)
2020
{
2121
FileName = fileName;
2222
UploadId = uploadId;
2323

24-
_arrayPool = arrayPool;
2524
_client = client;
2625
_encodedFileName = encodedFileName;
2726

28-
_parts = _arrayPool.Rent<string>(16);
27+
_parts = DefaultArrayPool.Instance.Rent<string>(16);
2928
}
3029

3130
/// <summary>
@@ -108,7 +107,7 @@ public async Task<bool> AddPart(byte[] data, int length, CancellationToken ct)
108107

109108
if (_parts.Length == _partCount)
110109
{
111-
CollectionUtils.Resize(ref _parts, _arrayPool, _partCount * 2);
110+
CollectionUtils.Resize(ref _parts, DefaultArrayPool.Instance, _partCount * 2);
112111
}
113112

114113
_parts[_partCount++] = partId;
@@ -126,7 +125,7 @@ public async Task<bool> AddPart(byte[] data, int length, CancellationToken ct)
126125
/// <returns>Возвращает результат загрузки</returns>
127126
public async Task<bool> AddParts(Stream data, CancellationToken ct)
128127
{
129-
_byteBuffer ??= _arrayPool.Rent<byte>(S3BucketClient.DefaultPartSize);
128+
_byteBuffer ??= DefaultArrayPool.Instance.Rent<byte>(S3BucketClient.DefaultPartSize);
130129

131130
while (true)
132131
{
@@ -198,12 +197,12 @@ public void Dispose()
198197
}
199198

200199
Array.Clear(_parts, 0, _partCount);
201-
_arrayPool.Return(_parts);
200+
DefaultArrayPool.Instance.Return(_parts);
202201
_parts = null!;
203202

204203
if (_byteBuffer is not null)
205204
{
206-
_arrayPool.Return(_byteBuffer);
205+
DefaultArrayPool.Instance.Return(_byteBuffer);
207206
_byteBuffer = null;
208207
}
209208

0 commit comments

Comments
 (0)