allow aliases to be / at the end and handle such cases (#4554)

This commit is contained in:
Harshavardhana
2023-04-21 11:30:52 -07:00
committed by GitHub
parent 6833118338
commit 0da22db3af
4 changed files with 12 additions and 6 deletions
+3 -3
View File
@@ -87,11 +87,11 @@ func mainClusterBucketExport(ctx *cli.Context) error {
fatalIf(probe.NewError(e).Trace(aliasedURL), "Unable to export bucket metadata.")
if bucket == "" {
bucket = "cluster"
bucket = "bucket"
}
// Create bucket metadata zip file
tmpFile, e := os.CreateTemp("", fmt.Sprintf("%s-metadata-", bucket))
tmpFile, e := os.CreateTemp("", fmt.Sprintf("%s-%s-metadata-", aliasedURL, bucket))
fatalIf(probe.NewError(e), "Unable to download file data.")
ext := "zip"
@@ -104,7 +104,7 @@ func mainClusterBucketExport(ctx *cli.Context) error {
tmpFile.Close()
// We use 4 bytes of the 32 bytes to identify the file.
downloadPath := fmt.Sprintf("%s-metadata.%s", bucket, ext)
downloadPath := fmt.Sprintf("%s-%s-metadata.%s", aliasedURL, bucket, ext)
fi, e := os.Stat(downloadPath)
if e == nil && !fi.IsDir() {
e = moveFile(downloadPath, downloadPath+"."+time.Now().Format(dateTimeFormatFilename))
+1 -1
View File
@@ -54,7 +54,7 @@ FLAGS:
{{end}}
EXAMPLES:
1. Recover bucket metadata for all buckets from previously saved bucket metadata backup.
{{.Prompt}} {{.HelpName}} myminio /backups/cluster-metadata.zip
{{.Prompt}} {{.HelpName}} myminio /backups/myminio-bucket-metadata.zip
`,
}
+4 -1
View File
@@ -22,6 +22,7 @@ import (
"fmt"
"io"
"os"
"path/filepath"
"time"
"github.com/fatih/color"
@@ -67,7 +68,9 @@ func mainClusterIAMExport(ctx *cli.Context) error {
// Get the alias parameter from cli
args := ctx.Args()
aliasedURL := args.Get(0)
aliasedURL := filepath.ToSlash(args.Get(0))
aliasedURL = filepath.Clean(aliasedURL)
console.SetColor("File", color.New(color.FgWhite, color.Bold))
// Create a new MinIO Admin Client
+4 -1
View File
@@ -22,6 +22,7 @@ import (
"fmt"
"io"
"os"
"path/filepath"
"github.com/klauspost/compress/zip"
"github.com/minio/cli"
@@ -66,7 +67,9 @@ func mainClusterIAMImport(ctx *cli.Context) error {
// Get the alias parameter from cli
args := ctx.Args()
aliasedURL := args.Get(0)
aliasedURL := filepath.ToSlash(args.Get(0))
aliasedURL = filepath.Clean(aliasedURL)
var r io.Reader
var sz int64
f, e := os.Open(args.Get(1))