1
0
mirror of https://github.com/minio/mc.git synced 2025-07-30 07:23:03 +03:00

Improve lock error message (#2353)

This commit is contained in:
Aditya Manthramurthy
2018-01-16 07:55:03 -08:00
committed by Nitish Tiwari
parent 5d703df69d
commit d9663e5d96
3 changed files with 18 additions and 2 deletions

View File

@ -105,6 +105,13 @@ func checkAdminLockClearSyntax(ctx *cli.Context) {
cli.ShowCommandHelpAndExit(ctx, "clear", 1)
}
// Check if a bucket is specified.
aliasedURL := filepath.ToSlash(ctx.Args().Get(0))
splits := splitStr(aliasedURL, "/", 3)
if splits[1] == "" {
fatalIf(errBucketNotSpecified().Trace(aliasedURL), "Cannot clear locks.")
}
if isForce := ctx.Bool("force"); isForce {
return
}
@ -132,7 +139,6 @@ func mainAdminLockClear(ctx *cli.Context) error {
fatalIf(err, "Cannot get a configured admin connection.")
aliasedURL = filepath.ToSlash(aliasedURL)
splits := splitStr(aliasedURL, "/", 3)
// Clear locks related to a specified pair of bucket and prefix

View File

@ -100,6 +100,13 @@ func checkAdminLockListSyntax(ctx *cli.Context) {
if len(ctx.Args()) == 0 || len(ctx.Args()) > 2 {
cli.ShowCommandHelpAndExit(ctx, "list", 1) // last argument is exit code
}
// Check if a bucket is specified.
aliasedURL := filepath.ToSlash(ctx.Args().Get(0))
splits := splitStr(aliasedURL, "/", 3)
if splits[1] == "" {
fatalIf(errBucketNotSpecified().Trace(aliasedURL), "Cannot list locks.")
}
}
func mainAdminLockList(ctx *cli.Context) error {
@ -119,7 +126,6 @@ func mainAdminLockList(ctx *cli.Context) error {
fatalIf(err, "Cannot get a configured admin connection.")
aliasedURL = filepath.ToSlash(aliasedURL)
splits := splitStr(aliasedURL, "/", 3)
// Fetch the lock info related to a specified pair of bucket and prefix

View File

@ -83,4 +83,8 @@ var (
errSourceTargetSame = func(URL string) *probe.Error {
return probe.NewError(errors.New("Source and target URL can not be same : " + URL)).Untrace()
}
errBucketNotSpecified = func() *probe.Error {
return probe.NewError(errors.New("This operation requires a " + "bucket to be specified.")).Untrace()
}
)