Skip to content

Commit c62f775

Browse files
committed
fixes path issue when reading dumps from s3. fixes #432
1 parent e160c24 commit c62f775

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pkg/storage/s3/s3.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ func (s *S3) Pull(ctx context.Context, source, target string, logger *log.Entry)
7575

7676
bucket, path := s.url.Hostname(), path.Join(s.url.Path, source)
7777

78+
path = strings.TrimPrefix(path, "/")
79+
7880
// Create a downloader with the session and default options
7981
downloader := manager.NewDownloader(client)
8082

@@ -86,7 +88,7 @@ func (s *S3) Pull(ctx context.Context, source, target string, logger *log.Entry)
8688
defer func() { _ = f.Close() }()
8789

8890
// Write the contents of S3 Object to the file
89-
n, err := downloader.Download(context.TODO(), f, &s3.GetObjectInput{
91+
n, err := downloader.Download(context.TODO(), f, &s3.GetObjectInput{
9092
Bucket: aws.String(bucket),
9193
Key: aws.String(path),
9294
})
@@ -194,7 +196,7 @@ func (s *S3) getClient(logger *log.Entry) (*s3.Client, error) {
194196
// Get the AWS config
195197
var configOpts []func(*config.LoadOptions) error // global client options
196198
if logger.Level == log.TraceLevel {
197-
configOpts = append(configOpts, config.WithClientLogMode(aws.LogRequestWithBody|aws.LogResponse))
199+
configOpts = append(configOpts, config.WithClientLogMode(aws.LogRequestWithBody|aws.LogResponse))
198200
}
199201
if s.region != "" {
200202
configOpts = append(configOpts, config.WithRegion(s.region))
@@ -206,7 +208,7 @@ func (s *S3) getClient(logger *log.Entry) (*s3.Client, error) {
206208
"",
207209
)))
208210
}
209-
cfg, err := config.LoadDefaultConfig(context.TODO(),
211+
cfg, err := config.LoadDefaultConfig(context.TODO(),
210212
configOpts...,
211213
)
212214
if err != nil {
@@ -215,7 +217,7 @@ func (s *S3) getClient(logger *log.Entry) (*s3.Client, error) {
215217

216218
// Get the S3 client
217219
var s3opts []func(*s3.Options) // s3 client options
218-
if s.endpoint != "" {
220+
if s.endpoint != "" {
219221
cleanEndpoint := getEndpoint(s.endpoint)
220222
s3opts = append(s3opts,
221223
func(o *s3.Options) {
@@ -231,7 +233,7 @@ func (s *S3) getClient(logger *log.Entry) (*s3.Client, error) {
231233
)
232234
}
233235

234-
// Create a new S3 service client
236+
// Create a new S3 service client
235237
return s3.NewFromConfig(cfg, s3opts...), nil
236238
}
237239

0 commit comments

Comments
 (0)