mirror of
https://github.com/gomods/athens
synced 2026-02-03 12:10:32 +00:00
Swith s3 ListObjects api to ListObjectsV2 (#2006)
Switch the ListObjects API used in s3 storage to ListObjectsV2
This commit is contained in:
@@ -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{
|
||||
lsParams := &s3.ListObjectsV2Input{
|
||||
Bucket: aws.String(s.bucket),
|
||||
Marker: &queryToken,
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user