From 783d29794a33fcc22c2a60bf533b94c7c15b695d Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 21 Apr 2016 17:10:14 -0700 Subject: [PATCH] ls: ls should ignore error BucketNameEmpty. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a valid case of 'ls', without this change. ``` $ mc ls localhost mc: Unable to stat ‘localhost’. Bucket name cannot be empty. ``` What we need to ideally see is if server is not available is ``` $ mc ls localhost mc: Unable to list folder. Get http://localhost:9000/: dial tcp [::1]:9000: getsockopt: connection refused ``` --- ls-main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ls-main.go b/ls-main.go index c497efee..6b4016c2 100644 --- a/ls-main.go +++ b/ls-main.go @@ -96,6 +96,11 @@ func checkListSyntax(ctx *cli.Context) { for _, url := range URLs { _, _, err := url2Stat(url) if err != nil && !isURLPrefixExists(url, isIncomplete) { + // Bucket name empty is a valid error for 'ls myminio', + // treat it as such. + if _, ok := err.ToGoError().(BucketNameEmpty); ok { + continue + } fatalIf(err.Trace(url), "Unable to stat ‘"+url+"’.") } }