allow aliases to be / at the end and handle such cases (#4554)
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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
|
||||
`,
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user