Make sure to error out if depth is -1 (#2828)

Current code silently converts -1 to 0, which
is not needed and we should fail instead.
This commit is contained in:
Harshavardhana
2019-07-18 14:40:51 +01:00
committed by kannappanr
parent bdcb9dcb2f
commit c2fcfe6512
+6 -11
View File
@@ -94,12 +94,12 @@ EXAMPLES:
3. List all buckets in "mybucket" on Amazon S3 cloud storage hosted on Microsoft Windows in a tree format.
$ {{.HelpName}} s3\mybucket\
4. List all buckets and objects in "mybucket" on Amazon S3 cloud storage in a tree format.
$ {{.HelpName}} -f myminio/mybucket/
$ {{.HelpName}} --files myminio/mybucket/
5. Set the depth of the tree for listing.
$ {{.HelpName}} -d 2 myminio/mybucket/
$ {{.HelpName}} --depth 2 myminio/mybucket/
6. List all the directories irrespective to the depth.
$ {{.HelpName}} myminio/mybucket/
@@ -110,16 +110,11 @@ EXAMPLES:
func checkTreeSyntax(ctx *cli.Context) {
args := ctx.Args()
var depth = -1
if ctx.IsSet("depth") {
depth = ctx.Int("depth")
if depth == -1 {
depth = 0
if ctx.Int("depth") <= 0 {
fatalIf(errInvalidArgument().Trace(args...), "depth should have a value greater than 0")
}
}
if depth != -1 && depth <= 0 {
fatalIf(errInvalidArgument().Trace(args...), "depth should have a value greater than 0")
}
if (args.Present()) && len(args) == 0 {
return