Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Fix listMultipart cannot get complete uploaded parts #28

Merged
merged 2 commits into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ func (i *storagePageStatus) ContinuationToken() string {

type partPageStatus struct {
key string
maxParts int64
partNumberMarker int64
maxParts int
partNumberMarker int
uploadId string
}

func (i *partPageStatus) ContinuationToken() string {
return strconv.FormatInt(i.partNumberMarker, 10)
return strconv.Itoa(i.partNumberMarker)
}
12 changes: 9 additions & 3 deletions storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,17 @@ func (s *Storage) nextPartObjectPageByPrefix(ctx context.Context, page *ObjectPa
func (s *Storage) nextPartPage(ctx context.Context, page *PartPage) error {
input := page.Status.(*partPageStatus)

output, err := s.bucket.ListUploadedParts(oss.InitiateMultipartUploadResult{
imur := oss.InitiateMultipartUploadResult{
Bucket: s.bucket.BucketName,
Key: input.key,
UploadID: input.uploadId,
})
}

options := make([]oss.Option, 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can set the cap of slice here to avoid more memory allocate if content is decided, e.g. make([]oss.Option, 0, 2).

options = append(options, oss.MaxParts(input.maxParts))
options = append(options, oss.PartNumberMarker(input.partNumberMarker))

output, err := s.bucket.ListUploadedParts(imur, options...)
if err != nil {
return err
}
Expand All @@ -337,7 +343,7 @@ func (s *Storage) nextPartPage(ctx context.Context, page *PartPage) error {
return IterateDone
}

partNumberMarker, err := strconv.ParseInt(output.NextPartNumberMarker, 10, 64)
partNumberMarker, err := strconv.Atoi(output.NextPartNumberMarker)
if err != nil {
return err
}
Expand Down