Skip to content

Commit

Permalink
Avoid segfaults, adapt for custom endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
oxpa committed Sep 4, 2024
1 parent 415288b commit 8e483e6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions experimental/s3_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (f *s3Storage) Walk(path string, baseDir string, fn walkFunc) error {
}
}

if *resp.IsTruncated {
if resp.IsTruncated != nil && *resp.IsTruncated {
atomic.AddInt64(&f.apiCalls, 1)
resp, err = f.S3.ListObjects(&s3.ListObjectsInput{
Bucket: aws.String(f.Bucket),
Expand Down Expand Up @@ -172,7 +172,7 @@ func (f *s3Storage) List(path string, fn walkFunc) error {
}
}

if *resp.IsTruncated {
if resp.IsTruncated != nil && *resp.IsTruncated {
atomic.AddInt64(&f.apiCalls, 1)
resp, err = f.S3.ListObjects(&s3.ListObjectsInput{
Bucket: aws.String(f.Bucket),
Expand Down Expand Up @@ -265,6 +265,10 @@ func newS3Storage(config *distributionStorageS3) (storageObject, error) {
awsConfig.Endpoint = config.RegionEndpoint
awsConfig.Region = config.Region

if config.RegionEndpoint != nil {
awsConfig.S3ForcePathStyle = aws.Bool(true)
}

if config.AccessKey != "" && config.SecretKey != "" {
awsConfig.Credentials = credentials.NewStaticCredentials(config.AccessKey, config.SecretKey, "")
}
Expand Down

0 comments on commit 8e483e6

Please sign in to comment.