Skip to content

Commit da33ad0

Browse files
azfile, azdatalake: Updating the type of number of chunks to uint64 (#22468)
1 parent 2b23e14 commit da33ad0

File tree

10 files changed

+171
-29
lines changed

10 files changed

+171
-29
lines changed

sdk/storage/azdatalake/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* Re-enabled `SharedKeyCredential` authentication mode for non TLS protected endpoints.
1313

1414
### Other Changes
15+
* Updated version of azblob to `1.3.1`
1516

1617
## 1.1.0 (2024-02-14)
1718

sdk/storage/azdatalake/file/client_test.go

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ import (
1212
"crypto/md5"
1313
"encoding/binary"
1414
"fmt"
15+
"github.com/Azure/azure-sdk-for-go/sdk/azcore/log"
1516
"hash/crc64"
1617
"io"
1718
"math/rand"
1819
"net/http"
1920
"os"
2021
"strconv"
2122
"strings"
23+
"sync/atomic"
2224
"testing"
2325
"time"
2426

@@ -4986,3 +4988,78 @@ func (s *UnrecordedTestSuite) TestFileCreateDeleteUsingOAuth() {
49864988
_, err = fClient.GetProperties(context.Background(), nil)
49874989
_require.NoError(err)
49884990
}
4991+
4992+
type fakeUploadBlob struct {
4993+
numChunks uint64
4994+
}
4995+
4996+
// nolint
4997+
func (f *fakeUploadBlob) Do(req *http.Request) (*http.Response, error) {
4998+
statusCode := http.StatusOK
4999+
5000+
// check how many times append data is called
5001+
if val, ok := req.URL.Query()["action"]; ok {
5002+
if val[0] == "append" {
5003+
statusCode = http.StatusAccepted
5004+
atomic.AddUint64(&f.numChunks, 1)
5005+
}
5006+
}
5007+
5008+
return &http.Response{
5009+
Request: req,
5010+
Status: "Created",
5011+
StatusCode: statusCode,
5012+
Header: http.Header{},
5013+
Body: http.NoBody,
5014+
}, nil
5015+
}
5016+
5017+
func TestUploadSmallChunkSize(t *testing.T) {
5018+
_require := require.New(t)
5019+
5020+
fileSize := int64(100 * 1024 * 1024)
5021+
chunkSize := int64(1024)
5022+
numChunks := uint64(((fileSize - 1) / chunkSize) + 1)
5023+
fbb := &fakeUploadBlob{}
5024+
5025+
log.SetListener(nil) // no logging
5026+
5027+
fClient, err := file.NewClientWithNoCredential("https://fake/blob/path", &file.ClientOptions{
5028+
ClientOptions: policy.ClientOptions{
5029+
Transport: fbb,
5030+
},
5031+
})
5032+
_require.NoError(err)
5033+
_require.NotNil(fClient)
5034+
5035+
// create local file
5036+
_, content := generateData(int(fileSize))
5037+
err = os.WriteFile("testFile", content, 0644)
5038+
_require.NoError(err)
5039+
5040+
defer func() {
5041+
err = os.Remove("testFile")
5042+
_require.NoError(err)
5043+
}()
5044+
5045+
fh, err := os.Open("testFile")
5046+
_require.NoError(err)
5047+
5048+
defer func(fh *os.File) {
5049+
err := fh.Close()
5050+
_require.NoError(err)
5051+
}(fh)
5052+
5053+
err = fClient.UploadFile(context.Background(), fh, &file.UploadFileOptions{ChunkSize: chunkSize})
5054+
_require.NoError(err)
5055+
5056+
_require.Equal(atomic.LoadUint64(&fbb.numChunks), numChunks)
5057+
5058+
// reset counter
5059+
atomic.StoreUint64(&fbb.numChunks, 0)
5060+
5061+
err = fClient.UploadBuffer(context.Background(), content, &file.UploadBufferOptions{ChunkSize: chunkSize})
5062+
_require.NoError(err)
5063+
5064+
_require.Equal(atomic.LoadUint64(&fbb.numChunks), numChunks)
5065+
}

sdk/storage/azdatalake/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2
77
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1
88
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2
9-
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.0
9+
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.1
1010
github.com/stretchr/testify v1.8.4
1111
)
1212

sdk/storage/azdatalake/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1/go.mod h1:h8hyGFDsU5HMiv
55
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 h1:LqbJ/WzJUwBf8UiaSzgX7aMclParm9/5Vgp+TY51uBQ=
66
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2/go.mod h1:yInRyqWXAuaPrgI7p70+lDDgh3mlBohis29jGMISnmc=
77
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.5.0 h1:AifHbc4mg0x9zW52WOpKbsHaDKuRhlI7TVl47thgQ70=
8-
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.0 h1:IfFdxTUDiV58iZqPKgyWiz4X4fCxZeQ1pTQPImLYXpY=
9-
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.0/go.mod h1:SUZc9YRRHfx2+FAQKNDGrssXehqLpxmwRv2mC/5ntj4=
8+
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.1 h1:fXPMAmuh0gDuRDey0atC8cXBuKIlqCzCkL8sm1n9Ov0=
9+
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.1/go.mod h1:SUZc9YRRHfx2+FAQKNDGrssXehqLpxmwRv2mC/5ntj4=
1010
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 h1:DzHpqpoJVaCgOUdVHxE8QB52S6NiVdDQvGlny1qvPqA=
1111
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI=
1212
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=

sdk/storage/azdatalake/internal/shared/batch_transfer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func DoBatchTransfer(ctx context.Context, o *BatchTransferOptions) error {
3232
}
3333

3434
// Prepare and do parallel operations.
35-
numChunks := uint16(((o.TransferSize - 1) / o.ChunkSize) + 1)
35+
numChunks := uint64(((o.TransferSize - 1) / o.ChunkSize) + 1)
3636
operationChannel := make(chan func() error, o.Concurrency) // Create the channel that release 'concurrency' goroutines concurrently
3737
operationResponseChannel := make(chan error, numChunks) // Holds each response
3838
ctx, cancel := context.WithCancel(ctx)
@@ -50,7 +50,7 @@ func DoBatchTransfer(ctx context.Context, o *BatchTransferOptions) error {
5050
}
5151

5252
// Add each chunk's operation to the channel.
53-
for chunkNum := uint16(0); chunkNum < numChunks; chunkNum++ {
53+
for chunkNum := uint64(0); chunkNum < numChunks; chunkNum++ {
5454
curChunkSize := o.ChunkSize
5555

5656
if chunkNum == numChunks-1 { // Last chunk
@@ -65,7 +65,7 @@ func DoBatchTransfer(ctx context.Context, o *BatchTransferOptions) error {
6565

6666
// Wait for the operations to complete.
6767
var firstErr error = nil
68-
for chunkNum := uint16(0); chunkNum < numChunks; chunkNum++ {
68+
for chunkNum := uint64(0); chunkNum < numChunks; chunkNum++ {
6969
responseError := <-operationResponseChannel
7070
// record the first error (the original error which should cause the other chunks to fail with canceled context)
7171
if responseError != nil && firstErr == nil {

sdk/storage/azfile/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
### Other Changes
1414

15+
* Updated `azidentity` version to `1.5.1`.
16+
1517
## 1.2.0 (2024-02-12)
1618

1719
### Other Changes

sdk/storage/azfile/file/client_test.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"crypto/rand"
1414
"encoding/binary"
1515
"fmt"
16+
"github.com/Azure/azure-sdk-for-go/sdk/azcore/log"
1617
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
1718
"github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming"
1819
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
@@ -34,6 +35,7 @@ import (
3435
"net/http"
3536
"os"
3637
"strings"
38+
"sync/atomic"
3739
"testing"
3840
"time"
3941
)
@@ -4624,4 +4626,64 @@ func (f *FileRecordedTestsSuite) TestFileClientAudienceNegative() {
46244626
testcommon.ValidateFileErrorCode(_require, err, fileerror.AuthenticationFailed)
46254627
}
46264628

4629+
type fakeDownloadFile struct {
4630+
contentSize int64
4631+
numChunks uint64
4632+
}
4633+
4634+
// nolint
4635+
func (f *fakeDownloadFile) Do(req *http.Request) (*http.Response, error) {
4636+
// check how many times range based get file is called
4637+
if _, ok := req.Header["x-ms-range"]; ok {
4638+
atomic.AddUint64(&f.numChunks, 1)
4639+
}
4640+
return &http.Response{
4641+
Request: req,
4642+
Status: "Created",
4643+
StatusCode: http.StatusOK,
4644+
Header: http.Header{"Content-Length": []string{fmt.Sprintf("%v", f.contentSize)}},
4645+
Body: http.NoBody,
4646+
}, nil
4647+
}
4648+
4649+
func TestDownloadSmallChunkSize(t *testing.T) {
4650+
_require := require.New(t)
4651+
4652+
fileSize := int64(100 * 1024 * 1024)
4653+
chunkSize := int64(1024)
4654+
numChunks := uint64(((fileSize - 1) / chunkSize) + 1)
4655+
fbb := &fakeDownloadFile{
4656+
contentSize: fileSize,
4657+
}
4658+
4659+
log.SetListener(nil) // no logging
4660+
4661+
fileClient, err := file.NewClientWithNoCredential("https://fake/file/path", &file.ClientOptions{
4662+
ClientOptions: policy.ClientOptions{
4663+
Transport: fbb,
4664+
},
4665+
})
4666+
_require.NoError(err)
4667+
_require.NotNil(fileClient)
4668+
4669+
// download to a temp file and verify contents
4670+
tmp, err := os.CreateTemp("", "")
4671+
_require.NoError(err)
4672+
defer tmp.Close()
4673+
4674+
_, err = fileClient.DownloadFile(context.Background(), tmp, &file.DownloadFileOptions{ChunkSize: chunkSize})
4675+
_require.NoError(err)
4676+
4677+
_require.Equal(atomic.LoadUint64(&fbb.numChunks), numChunks)
4678+
4679+
// reset counter
4680+
atomic.StoreUint64(&fbb.numChunks, 0)
4681+
4682+
buff := make([]byte, fileSize)
4683+
_, err = fileClient.DownloadBuffer(context.Background(), buff, &file.DownloadBufferOptions{ChunkSize: chunkSize})
4684+
_require.NoError(err)
4685+
4686+
_require.Equal(atomic.LoadUint64(&fbb.numChunks), numChunks)
4687+
}
4688+
46274689
// TODO: Add tests for retry header options

sdk/storage/azfile/go.mod

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ go 1.18
44

55
require (
66
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2
7-
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0
7+
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1
88
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2
9-
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0
9+
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.1
1010
github.com/stretchr/testify v1.8.4
1111
)
1212

1313
require (
14-
github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect
14+
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 // indirect
1515
github.com/davecgh/go-spew v1.1.1 // indirect
1616
github.com/dnaeon/go-vcr v1.2.0 // indirect
17-
github.com/golang-jwt/jwt/v5 v5.0.0 // indirect
18-
github.com/google/uuid v1.3.1 // indirect
17+
github.com/golang-jwt/jwt/v5 v5.2.0 // indirect
18+
github.com/google/uuid v1.6.0 // indirect
1919
github.com/kylelemons/godebug v1.1.0 // indirect
20-
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
20+
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
2121
github.com/pmezard/go-difflib v1.0.0 // indirect
2222
golang.org/x/crypto v0.18.0 // indirect
2323
golang.org/x/net v0.20.0 // indirect

sdk/storage/azfile/go.sum

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 h1:c4k2FIYIh4xtwqrQwV0Ct1v5+ehlNXj5NI/MWVsiTkQ=
22
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2/go.mod h1:5FDJtLEO/GxwNgUxbwrY3LP0pEoThTQJtk2oysdXHxM=
3-
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI=
4-
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs=
3+
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1 h1:sO0/P7g68FrryJzljemN+6GTssUXdANk6aJ7T1ZxnsQ=
4+
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1/go.mod h1:h8hyGFDsU5HMivxiS2iYFZsgDbU9OnnJ163x5UGVKYo=
55
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 h1:LqbJ/WzJUwBf8UiaSzgX7aMclParm9/5Vgp+TY51uBQ=
66
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2/go.mod h1:yInRyqWXAuaPrgI7p70+lDDgh3mlBohis29jGMISnmc=
7-
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.2.0 h1:Ma67P/GGprNwsslzEH6+Kb8nybI8jpDTm4Wmzu2ReK8=
8-
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0 h1:gggzg0SUMs6SQbEw+3LoSsYf9YMjkupeAnHMX8O9mmY=
9-
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0/go.mod h1:+6KLcKIVgxoBDMqMO/Nvy7bZ9a0nbU3I1DtFQK3YvB4=
10-
github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk=
11-
github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI=
7+
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.5.0 h1:AifHbc4mg0x9zW52WOpKbsHaDKuRhlI7TVl47thgQ70=
8+
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.1 h1:fXPMAmuh0gDuRDey0atC8cXBuKIlqCzCkL8sm1n9Ov0=
9+
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.1/go.mod h1:SUZc9YRRHfx2+FAQKNDGrssXehqLpxmwRv2mC/5ntj4=
10+
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 h1:DzHpqpoJVaCgOUdVHxE8QB52S6NiVdDQvGlny1qvPqA=
11+
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI=
1212
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1313
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1414
github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI=
1515
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
16-
github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE=
17-
github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
18-
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
19-
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
16+
github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1Jw=
17+
github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
18+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
19+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
2020
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
2121
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
2222
github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8=
23-
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU=
24-
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
23+
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
24+
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
2525
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
2626
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2727
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
@@ -30,7 +30,7 @@ golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
3030
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
3131
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
3232
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
33-
golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
33+
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
3434
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
3535
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
3636
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=

sdk/storage/azfile/internal/shared/batch_transfer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func DoBatchTransfer(ctx context.Context, o *BatchTransferOptions) error {
3232
}
3333

3434
// Prepare and do parallel operations.
35-
numChunks := uint16(((o.TransferSize - 1) / o.ChunkSize) + 1)
35+
numChunks := uint64(((o.TransferSize - 1) / o.ChunkSize) + 1)
3636
operationChannel := make(chan func() error, o.Concurrency) // Create the channel that release 'concurrency' goroutines concurrently
3737
operationResponseChannel := make(chan error, numChunks) // Holds each response
3838
ctx, cancel := context.WithCancel(ctx)
@@ -50,7 +50,7 @@ func DoBatchTransfer(ctx context.Context, o *BatchTransferOptions) error {
5050
}
5151

5252
// Add each chunk's operation to the channel.
53-
for chunkNum := uint16(0); chunkNum < numChunks; chunkNum++ {
53+
for chunkNum := uint64(0); chunkNum < numChunks; chunkNum++ {
5454
curChunkSize := o.ChunkSize
5555

5656
if chunkNum == numChunks-1 { // Last chunk
@@ -65,7 +65,7 @@ func DoBatchTransfer(ctx context.Context, o *BatchTransferOptions) error {
6565

6666
// Wait for the operations to complete.
6767
var firstErr error = nil
68-
for chunkNum := uint16(0); chunkNum < numChunks; chunkNum++ {
68+
for chunkNum := uint64(0); chunkNum < numChunks; chunkNum++ {
6969
responseError := <-operationResponseChannel
7070
// record the first error (the original error which should cause the other chunks to fail with canceled context)
7171
if responseError != nil && firstErr == nil {

0 commit comments

Comments
 (0)