Skip to content

Commit

Permalink
fix searchPrefix when directory is at root
Browse files Browse the repository at this point in the history
Signed-off-by: Yujie Zhu <yujiezhu718@gmail.com>
  • Loading branch information
y00j committed Oct 14, 2020
1 parent b4d1ced commit 287def5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
11 changes: 8 additions & 3 deletions go/vt/mysqlctl/azblobbackupstorage/azblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,20 @@ func (bs *AZBlobBackupStorage) containerURL() (*azblob.ContainerURL, error) {

// ListBackups implements BackupStorage.
func (bs *AZBlobBackupStorage) ListBackups(ctx context.Context, dir string) ([]backupstorage.BackupHandle, error) {
log.Infof("ListBackups: [azblob] container: %s, directory: %v", *containerName, objName(dir, ""))
var searchPrefix string
if dir == "/" {
searchPrefix = "/"
} else {
searchPrefix = objName(dir, "")
}

log.Infof("ListBackups: [azblob] container: %s, directory: %v", *containerName, searchPrefix)

containerURL, err := bs.containerURL()
if err != nil {
return nil, err
}

searchPrefix := objName(dir, "")

result := make([]backupstorage.BackupHandle, 0)
var subdirs []string

Expand Down
9 changes: 8 additions & 1 deletion go/vt/mysqlctl/gcsbackupstorage/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,14 @@ func (bs *GCSBackupStorage) ListBackups(ctx context.Context, dir string) ([]back

// List prefixes that begin with dir (i.e. list subdirs).
var subdirs []string
searchPrefix := objName(dir, "" /* include trailing slash */)

var searchPrefix string
if dir == "/" {
searchPrefix = ""
} else {
searchPrefix = objName(dir, "" /* include trailing slash */)
}

query := &storage.Query{
Delimiter: "/",
Prefix: searchPrefix,
Expand Down

0 comments on commit 287def5

Please sign in to comment.