Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

binlog-collector: normalize duplicate slashes in the bucket path #1943

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
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
4 changes: 4 additions & 0 deletions cmd/pitr/collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"log"
"os"
"os/exec"
"path"
"strings"
"syscall"
"time"
Expand Down Expand Up @@ -118,6 +119,8 @@ func New(ctx context.Context, c Config) (*Collector, error) {
if len(bucketArr) > 1 {
prefix = strings.TrimPrefix(c.BackupStorageS3.BucketURL, bucketArr[0]+"/") + "/"
}
// if c.S3BucketURL ends with "/", we need prefix to be like "data/more-data/", not "data/more-data//"
prefix = path.Clean(prefix) + "/"
s, err = storage.NewS3(ctx, c.BackupStorageS3.Endpoint, c.BackupStorageS3.AccessKeyID, c.BackupStorageS3.AccessKey, bucketArr[0], prefix, c.BackupStorageS3.Region, c.VerifyTLS)
if err != nil {
return nil, errors.Wrap(err, "new storage manager")
Expand All @@ -127,6 +130,7 @@ func New(ctx context.Context, c Config) (*Collector, error) {
if prefix != "" {
prefix += "/"
}
prefix = path.Clean(prefix) + "/"
s, err = storage.NewAzure(c.BackupStorageAzure.AccountName, c.BackupStorageAzure.AccountKey, c.BackupStorageAzure.Endpoint, container, prefix)
if err != nil {
return nil, errors.Wrap(err, "new azure storage")
Expand Down
Loading