Skip to content

Commit

Permalink
Update s3store to newer AWS SDK for Go
Browse files Browse the repository at this point in the history
  • Loading branch information
Acconut committed Dec 5, 2023
1 parent 1daf26b commit 4582a61
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 78 deletions.
24 changes: 12 additions & 12 deletions pkg/s3store/s3store.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ func (upload *s3Upload) writeInfo(ctx context.Context, info handler.FileInfo) er
Bucket: aws.String(store.Bucket),
Key: store.metadataKeyWithPrefix(upload.objectId + ".info"),
Body: bytes.NewReader(infoJson),
ContentLength: int64(len(infoJson)),
ContentLength: aws.Int64(int64(len(infoJson))),
})
store.observeRequestDuration(t, metricPutInfoObject)

Expand Down Expand Up @@ -507,7 +507,7 @@ func (upload *s3Upload) uploadParts(ctx context.Context, offset int64, src io.Re
Bucket: aws.String(store.Bucket),
Key: store.keyWithPrefix(upload.objectId),
UploadId: aws.String(upload.multipartId),
PartNumber: part.number,
PartNumber: aws.Int32(part.number),
}
etag, err := upload.putPartForUpload(ctx, uploadPartInput, file, part.size)
store.observeRequestDuration(t, metricUploadPart)
Expand Down Expand Up @@ -743,7 +743,7 @@ func (upload s3Upload) GetReader(ctx context.Context) (io.ReadCloser, error) {
Bucket: aws.String(store.Bucket),
Key: store.keyWithPrefix(upload.objectId),
UploadId: aws.String(upload.multipartId),
MaxParts: 0,
MaxParts: aws.Int32(0),
})
if err == nil {
// The multipart upload still exists, which means we cannot download it yet
Expand Down Expand Up @@ -800,7 +800,7 @@ func (upload s3Upload) Terminate(ctx context.Context) error {
Key: store.metadataKeyWithPrefix(upload.objectId + ".info"),
},
},
Quiet: true,
Quiet: aws.Bool(true),
},
})

Expand Down Expand Up @@ -842,7 +842,7 @@ func (upload s3Upload) FinishUpload(ctx context.Context) error {
Bucket: aws.String(store.Bucket),
Key: store.keyWithPrefix(upload.objectId),
UploadId: aws.String(upload.multipartId),
PartNumber: 1,
PartNumber: aws.Int32(1),
Body: bytes.NewReader([]byte{}),
})
if err != nil {
Expand All @@ -866,7 +866,7 @@ func (upload s3Upload) FinishUpload(ctx context.Context) error {
for index, part := range parts {
completedParts[index] = types.CompletedPart{
ETag: aws.String(part.etag),
PartNumber: part.number,
PartNumber: aws.Int32(part.number),
}
}

Expand Down Expand Up @@ -992,7 +992,7 @@ func (upload *s3Upload) concatUsingMultipart(ctx context.Context, partialUploads
Bucket: aws.String(store.Bucket),
Key: store.keyWithPrefix(upload.objectId),
UploadId: aws.String(upload.multipartId),
PartNumber: partNumber,
PartNumber: aws.Int32(partNumber),
CopySource: aws.String(store.Bucket + "/" + *store.keyWithPrefix(sourceObject)),
})
if err != nil {
Expand Down Expand Up @@ -1044,13 +1044,13 @@ func (store S3Store) listAllParts(ctx context.Context, objectId string, multipar
parts = slices.Grow(parts, len(parts)+len((*listPtr).Parts))
for _, part := range (*listPtr).Parts {
parts = append(parts, &s3Part{
number: part.PartNumber,
size: part.Size,
number: *part.PartNumber,
size: *part.Size,
etag: *part.ETag,
})
}

if listPtr.IsTruncated {
if listPtr.IsTruncated != nil && *listPtr.IsTruncated {
partMarker = listPtr.NextPartNumberMarker
} else {
break
Expand Down Expand Up @@ -1081,7 +1081,7 @@ func (store S3Store) downloadIncompletePartForUpload(ctx context.Context, upload
if err != nil {
return nil, err
}
if n < incompleteUploadObject.ContentLength {
if n < *incompleteUploadObject.ContentLength {
return nil, errors.New("short read of incomplete upload")
}

Expand Down Expand Up @@ -1121,7 +1121,7 @@ func (store S3Store) headIncompletePartForUpload(ctx context.Context, uploadId s
return 0, err
}

return obj.ContentLength, nil
return *obj.ContentLength, nil
}

func (store S3Store) putIncompletePartForUpload(ctx context.Context, uploadId string, file io.ReadSeeker) error {
Expand Down
Loading

0 comments on commit 4582a61

Please sign in to comment.