Skip to content

Commit

Permalink
Swith s3 ListObjects api to ListObjectsV2
Browse files Browse the repository at this point in the history
  • Loading branch information
yatesliang committed Nov 18, 2024
1 parent e53c524 commit 6496e1b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions pkg/storage/s3/cataloger.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ func (s *Storage) Catalog(ctx context.Context, token string, pageSize int) ([]pa
res := make([]paths.AllPathParams, 0)
count := pageSize
for count > 0 {
lsParams := &s3.ListObjectsInput{
Bucket: aws.String(s.bucket),
Marker: &queryToken,
lsParams := &s3.ListObjectsV2Input{
Bucket: aws.String(s.bucket),
StartAfter: &queryToken,
}

loo, err := s.s3API.ListObjects(ctx, lsParams)
loo, err := s.s3API.ListObjectsV2(ctx, lsParams)
if err != nil {
return nil, "", errors.E(op, err)
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/storage/s3/lister.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ func (s *Storage) List(ctx context.Context, module string) ([]string, error) {
defer span.End()

modulePrefix := strings.TrimSuffix(module, "/") + "/@v"
lsParams := &s3.ListObjectsInput{

lsParams := &s3.ListObjectsV2Input{
Bucket: aws.String(s.bucket),
Prefix: aws.String(modulePrefix),
}

loo, err := s.s3API.ListObjects(ctx, lsParams)
loo, err := s.s3API.ListObjectsV2(ctx, lsParams)
if err != nil {
return nil, errors.E(op, err, errors.M(module))
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/s3/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (s *Storage) clear() error {
ctx, cancel := context.WithTimeout(context.Background(), s.timeout)
defer cancel()

objects, err := s.s3API.ListObjects(ctx, &s3.ListObjectsInput{Bucket: aws.String(s.bucket)})
objects, err := s.s3API.ListObjectsV2(ctx, &s3.ListObjectsV2Input{Bucket: aws.String(s.bucket)})
if err != nil {
return err
}
Expand Down

0 comments on commit 6496e1b

Please sign in to comment.