diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 03deff95..d2232a90 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -7,7 +7,7 @@ "Deps": [ { "ImportPath": "github.com/dustin/go-humanize", - "Rev": "00897f070f09f194c26d65afae734ba4c32404e8" + "Rev": "c128122e0b9b93799aef8181a537e5d8fd7081d6" }, { "ImportPath": "github.com/fatih/color", @@ -29,13 +29,13 @@ }, { "ImportPath": "github.com/minio/minio-go", - "Comment": "v0.2.0-12-g20db439", - "Rev": "20db439bc6671562eeff32d4cc3381eb7e824671" + "Comment": "v0.2.0-16-gd4b3d1e", + "Rev": "d4b3d1ecfb717775481044e72cc10cc0d534dc0c" }, { "ImportPath": "github.com/minio/minio/pkg/probe", - "Comment": "release-1434511043-296-g7f13095", - "Rev": "7f1309526056653a8e07277b3e39bfc49766363a" + "Comment": "release-1434511043-300-g28d9565", + "Rev": "28d9565400d68ae1cd79b81075823f10775e6230" }, { "ImportPath": "github.com/minio/pb", @@ -56,7 +56,7 @@ }, { "ImportPath": "gopkg.in/check.v1", - "Rev": "11d3bc7aa68e238947792f30573146a3231fc0f1" + "Rev": "b3d3430320d4260e5fea99841af984b3badcea63" } ] } diff --git a/Godeps/_workspace/src/github.com/dustin/go-humanize/bigbytes.go b/Godeps/_workspace/src/github.com/dustin/go-humanize/bigbytes.go index 6876e92e..e4a814a9 100644 --- a/Godeps/_workspace/src/github.com/dustin/go-humanize/bigbytes.go +++ b/Godeps/_workspace/src/github.com/dustin/go-humanize/bigbytes.go @@ -115,7 +115,7 @@ func humanateBigBytes(s, base *big.Int, sizes []string) string { // // BigBytes(82854982) -> 83MB func BigBytes(s *big.Int) string { - sizes := []string{"B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"} + sizes := []string{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"} return humanateBigBytes(s, bigSIExp, sizes) } diff --git a/Godeps/_workspace/src/github.com/dustin/go-humanize/bigbytes_test.go b/Godeps/_workspace/src/github.com/dustin/go-humanize/bigbytes_test.go index a0f977a6..da367d41 100644 --- a/Godeps/_workspace/src/github.com/dustin/go-humanize/bigbytes_test.go +++ b/Godeps/_workspace/src/github.com/dustin/go-humanize/bigbytes_test.go @@ -86,8 +86,8 @@ func TestBigBytes(t *testing.T) { {"bytes(803)", bbyte(803), "803B"}, {"bytes(999)", bbyte(999), "999B"}, - {"bytes(1024)", bbyte(1024), "1.0KB"}, - {"bytes(1MB - 1)", bbyte(MByte - Byte), "1000KB"}, + {"bytes(1024)", bbyte(1024), "1.0kB"}, + {"bytes(1MB - 1)", bbyte(MByte - Byte), "1000kB"}, {"bytes(1MB)", bbyte(1024 * 1024), "1.0MB"}, {"bytes(1GB - 1K)", bbyte(GByte - KByte), "1000MB"}, diff --git a/Godeps/_workspace/src/github.com/dustin/go-humanize/bytes.go b/Godeps/_workspace/src/github.com/dustin/go-humanize/bytes.go index 4c4b5af1..b7a77b52 100644 --- a/Godeps/_workspace/src/github.com/dustin/go-humanize/bytes.go +++ b/Godeps/_workspace/src/github.com/dustin/go-humanize/bytes.go @@ -86,7 +86,7 @@ func humanateBytes(s uint64, base float64, sizes []string) string { // // Bytes(82854982) -> 83MB func Bytes(s uint64) string { - sizes := []string{"B", "KB", "MB", "GB", "TB", "PB", "EB"} + sizes := []string{"B", "kB", "MB", "GB", "TB", "PB", "EB"} return humanateBytes(s, 1000, sizes) } diff --git a/Godeps/_workspace/src/github.com/dustin/go-humanize/bytes_test.go b/Godeps/_workspace/src/github.com/dustin/go-humanize/bytes_test.go index 76a594c1..7497fa00 100644 --- a/Godeps/_workspace/src/github.com/dustin/go-humanize/bytes_test.go +++ b/Godeps/_workspace/src/github.com/dustin/go-humanize/bytes_test.go @@ -80,9 +80,9 @@ func TestBytes(t *testing.T) { {"bytes(803)", Bytes(803), "803B"}, {"bytes(999)", Bytes(999), "999B"}, - {"bytes(1024)", Bytes(1024), "1.0KB"}, - {"bytes(9999)", Bytes(9999), "10KB"}, - {"bytes(1MB - 1)", Bytes(MByte - Byte), "1000KB"}, + {"bytes(1024)", Bytes(1024), "1.0kB"}, + {"bytes(9999)", Bytes(9999), "10kB"}, + {"bytes(1MB - 1)", Bytes(MByte - Byte), "1000kB"}, {"bytes(1MB)", Bytes(1024 * 1024), "1.0MB"}, {"bytes(1GB - 1K)", Bytes(GByte - KByte), "1000MB"}, diff --git a/Godeps/_workspace/src/github.com/dustin/go-humanize/comma.go b/Godeps/_workspace/src/github.com/dustin/go-humanize/comma.go index 9d0d2ed1..20711c15 100644 --- a/Godeps/_workspace/src/github.com/dustin/go-humanize/comma.go +++ b/Godeps/_workspace/src/github.com/dustin/go-humanize/comma.go @@ -18,7 +18,7 @@ func Comma(v int64) string { v = 0 - v } - parts := []string{"", "", "", "", "", "", "", ""} + parts := []string{"", "", "", "", "", "", ""} j := len(parts) - 1 for v > 999 { diff --git a/Godeps/_workspace/src/github.com/minio/minio-go/common.go b/Godeps/_workspace/src/github.com/minio/minio-go/common.go index 6263d559..774a544f 100644 --- a/Godeps/_workspace/src/github.com/minio/minio-go/common.go +++ b/Godeps/_workspace/src/github.com/minio/minio-go/common.go @@ -69,7 +69,7 @@ func urlEncodeName(name string) (string, error) { continue } switch s { - case '-', '_', '.', '~', '/': // §2.3 Unreserved characters (mark) + case '-', '_', '.', '~', '/', '+': // §2.3 Unreserved characters (mark) encodedName = encodedName + string(s) continue default: diff --git a/Godeps/_workspace/src/github.com/minio/minio-go/request.go b/Godeps/_workspace/src/github.com/minio/minio-go/request.go index 730b82d4..c24ca850 100644 --- a/Godeps/_workspace/src/github.com/minio/minio-go/request.go +++ b/Godeps/_workspace/src/github.com/minio/minio-go/request.go @@ -82,6 +82,23 @@ var ignoredHeaders = map[string]bool{ "User-Agent": true, } +func path2BucketAndObject(path string) (bucketName, objectName string) { + pathSplits := strings.SplitN(path, "?", 2) + splits := strings.SplitN(pathSplits[0], separator, 3) + switch len(splits) { + case 0, 1: + bucketName = "" + objectName = "" + case 2: + bucketName = splits[1] + objectName = "" + case 3: + bucketName = splits[1] + objectName = splits[2] + } + return bucketName, objectName +} + // path2Object gives objectName from URL path func path2Object(path string) (objectName string) { pathSplits := strings.SplitN(path, "?", 2) @@ -277,6 +294,7 @@ func (r *request) getCanonicalRequest(hashedPayload string) string { encodedPath, _ := urlEncodeName(r.req.URL.Path) // convert any space strings back to "+" encodedPath = strings.Replace(encodedPath, "+", "%20", -1) + encodedPath = strings.Replace(encodedPath, "%2B", "+", -1) canonicalRequest := strings.Join([]string{ r.req.Method, encodedPath, diff --git a/Godeps/_workspace/src/github.com/minio/minio/pkg/probe/probe.go b/Godeps/_workspace/src/github.com/minio/minio/pkg/probe/probe.go index 078d2391..957c3384 100644 --- a/Godeps/_workspace/src/github.com/minio/minio/pkg/probe/probe.go +++ b/Godeps/_workspace/src/github.com/minio/minio/pkg/probe/probe.go @@ -71,6 +71,9 @@ type Error struct { // trace the return path with Probe.Trace and finally handle reporting or quitting // at the top level. func New(e error) *Error { + if e == nil { + return nil + } Err := Error{sync.RWMutex{}, e, GetSysInfo(), []tracePoint{}} return Err.trace() } diff --git a/Godeps/_workspace/src/gopkg.in/check.v1/check.go b/Godeps/_workspace/src/gopkg.in/check.v1/check.go index c99392a2..f302a053 100644 --- a/Godeps/_workspace/src/gopkg.in/check.v1/check.go +++ b/Godeps/_workspace/src/gopkg.in/check.v1/check.go @@ -335,7 +335,7 @@ func (c *C) logPanic(skip int, value interface{}) { if name == "Value.call" && strings.HasSuffix(path, valueGo) { continue } - if (name == "call16" || name == "call32") && strings.Contains(path, asmGo) { + if name == "call16" && strings.Contains(path, asmGo) { continue } c.logf("%s:%d\n in %s", nicePath(file), line, name) diff --git a/access-main.go b/access-main.go index 74851407..a010a8f3 100644 --- a/access-main.go +++ b/access-main.go @@ -64,14 +64,14 @@ func runAccessCmd(ctx *cli.Context) { config := mustGetMcConfig() acl := bucketACL(ctx.Args().First()) if !acl.isValidBucketACL() { - ifFatal(probe.New(errInvalidACL{acl: acl.String()})) + Fatal(probe.New(errInvalidACL{acl: acl.String()})) } for _, arg := range ctx.Args().Tail() { targetURL, err := getExpandedURL(arg, config.Aliases) - ifFatal(err) + Fatal(err) err = doUpdateAccessCmd(targetURL, acl) - ifFatal(err) + Fatal(err) } } diff --git a/cat-main.go b/cat-main.go index b0f1ead6..67b36948 100644 --- a/cat-main.go +++ b/cat-main.go @@ -67,8 +67,8 @@ func runCatCmd(ctx *cli.Context) { // Convert arguments to URLs: expand alias, fix format... for _, arg := range ctx.Args() { sourceURL, err := getExpandedURL(arg, config.Aliases) - ifFatal(err) - ifFatal(doCatCmd(sourceURL)) + Fatal(err) + Fatal(doCatCmd(sourceURL)) } } diff --git a/config-main.go b/config-main.go index 849fa87c..d5867c86 100644 --- a/config-main.go +++ b/config-main.go @@ -67,7 +67,7 @@ func runConfigCmd(ctx *cli.Context) { console.Fatalf("Incorrect number of arguments, please read \"mc config help\". %s", errInvalidArgument{}) } msg, err := doConfig(arg, tailArgs) - ifFatal(err) + Fatal(err) console.Infoln(msg) } diff --git a/config.go b/config.go index 60def2cf..49fb5a0b 100644 --- a/config.go +++ b/config.go @@ -66,7 +66,7 @@ func getMcConfigDir() (string, *probe.Error) { // mustGetMcConfigDir - construct minio client config folder or fail func mustGetMcConfigDir() (configDir string) { configDir, err := getMcConfigDir() - ifFatal(err) + Fatal(err) return configDir } @@ -94,7 +94,7 @@ func getMcConfigPath() (string, *probe.Error) { // mustGetMcConfigPath - similar to getMcConfigPath, ignores errors func mustGetMcConfigPath() string { path, err := getMcConfigPath() - ifFatal(err) + Fatal(err) return path } @@ -132,7 +132,7 @@ func getMcConfig() (*configV1, *probe.Error) { // mustGetMcConfig - reads configuration file and returns configs, exits on error func mustGetMcConfig() *configV1 { config, err := getMcConfig() - ifFatal(err) + Fatal(err) return config } @@ -175,9 +175,9 @@ func migrateConfigV1ToV101() { } conf := newConfigV1() config, err := quick.New(conf) - ifFatal(err) + Fatal(err) err = config.Load(mustGetMcConfigPath()) - ifFatal(err) + Fatal(err) conf = config.Data().(*configV1) // version is the same return @@ -206,9 +206,9 @@ func migrateConfigV1ToV101() { { newConfig, err := quick.New(conf) - ifFatal(err) + Fatal(err) err = newConfig.Save(mustGetMcConfigPath()) - ifFatal(err) + Fatal(err) } console.Infof("Successfully migrated %s from version: %s to version: %s\n", mustGetMcConfigPath(), mcPreviousConfigVersion, mcCurrentConfigVersion) @@ -286,6 +286,6 @@ func newConfig() (config quick.Config, err *probe.Error) { // mustNewConfig instantiates a new config handler, exists upon error func mustNewConfig() quick.Config { config, err := newConfig() - ifFatal(err) + Fatal(err) return config } diff --git a/cp-main.go b/cp-main.go index 5e8a946e..495ef8f5 100644 --- a/cp-main.go +++ b/cp-main.go @@ -154,7 +154,7 @@ func doPrepareCopyURLs(session *sessionV2, trapCh <-chan bool) { break } if cpURLs.Error != nil { - ifError(cpURLs.Error) + Error(cpURLs.Error) break } @@ -221,7 +221,7 @@ func doCopyCmdSession(session *sessionV2) { session.Header.LastCopied = cpURLs.SourceContent.Name } else { console.Println() - ifError(cpURLs.Error) + Error(cpURLs.Error) } case <-trapCh: // Receive interrupt notification. session.Close() diff --git a/cp-url.go b/cp-url.go index b9687cb1..c690e7ce 100644 --- a/cp-url.go +++ b/cp-url.go @@ -108,12 +108,12 @@ func checkCopySyntaxTypeA(srcURLs []string, tgtURL string) { } srcURL := srcURLs[0] _, srcContent, err := url2Stat(srcURL) - ifFatal(err) + Fatal(err) if srcContent.Type.IsDir() { console.Fatalf("Source ‘%s’ is a folder. Use ‘%s...’ argument to copy this folder and its contents recursively. %s\n", srcURL, srcURL, errInvalidArgument{}) } if !srcContent.Type.IsRegular() { - ifFatal(probe.New(errSourceIsNotFile{URL: srcURL})) + Fatal(probe.New(errSourceIsNotFile{URL: srcURL})) } } @@ -124,19 +124,19 @@ func checkCopySyntaxTypeB(srcURLs []string, tgtURL string) { } srcURL := srcURLs[0] _, srcContent, err := url2Stat(srcURL) - ifFatal(err) + Fatal(err) if srcContent.Type.IsDir() { console.Fatalf("Source ‘%s’ is a folder. Use ‘%s...’ argument to copy this folder and its contents recursively. %s\n", srcURL, srcURL, errInvalidArgument{}) } if !srcContent.Type.IsRegular() { - ifFatal(probe.New(errSourceIsNotFile{URL: srcURL})) + Fatal(probe.New(errSourceIsNotFile{URL: srcURL})) } _, tgtContent, err := url2Stat(tgtURL) // Target exist?. if err == nil { if !tgtContent.Type.IsDir() { - ifFatal(probe.New(errTargetIsNotDir{URL: tgtURL})) + Fatal(probe.New(errTargetIsNotDir{URL: tgtURL})) } } } @@ -149,16 +149,16 @@ func checkCopySyntaxTypeC(srcURLs []string, tgtURL string) { srcURL := srcURLs[0] srcURL = stripRecursiveURL(srcURL) _, srcContent, err := url2Stat(srcURL) - ifFatal(err) + Fatal(err) if srcContent.Type.IsRegular() { // Ellipses is supported only for folders. - ifFatal(probe.New(errSourceIsNotDir{URL: srcURL})) + Fatal(probe.New(errSourceIsNotDir{URL: srcURL})) } _, tgtContent, err := url2Stat(tgtURL) // Target exist?. if err == nil { if !tgtContent.Type.IsDir() { - ifFatal(probe.New(errTargetIsNotDir{URL: tgtURL})) + Fatal(probe.New(errTargetIsNotDir{URL: tgtURL})) } } } @@ -169,18 +169,18 @@ func checkCopySyntaxTypeD(srcURLs []string, tgtURL string) { if isURLRecursive(srcURL) { srcURL = stripRecursiveURL(srcURL) _, srcContent, err := url2Stat(srcURL) - ifFatal(err) + Fatal(err) if !srcContent.Type.IsDir() { // Ellipses is supported only for folders. - ifFatal(probe.New(errSourceIsNotDir{URL: srcURL})) + Fatal(probe.New(errSourceIsNotDir{URL: srcURL})) } } else { // Regular URL. _, srcContent, err := url2Stat(srcURL) - ifFatal(err) + Fatal(err) if srcContent.Type.IsDir() { console.Fatalf("Source ‘%s’ is a folder. Use ‘%s...’ argument to copy this folder and its contents recursively. %s\n", srcURL, srcURL, errInvalidArgument{}) } if !srcContent.Type.IsRegular() { - ifFatal(probe.New(errSourceIsNotFile{URL: srcURL})) + Fatal(probe.New(errSourceIsNotFile{URL: srcURL})) } } } @@ -188,7 +188,7 @@ func checkCopySyntaxTypeD(srcURLs []string, tgtURL string) { // Target exist?. if err == nil { if !tgtContent.Type.IsDir() { - ifFatal(probe.New(errTargetIsNotDir{URL: tgtURL})) + Fatal(probe.New(errTargetIsNotDir{URL: tgtURL})) } } } diff --git a/diff-main.go b/diff-main.go index 1bce03c9..a0d95169 100644 --- a/diff-main.go +++ b/diff-main.go @@ -63,9 +63,9 @@ func runDiffCmd(ctx *cli.Context) { var err *probe.Error firstURL, err = getExpandedURL(firstURL, config.Aliases) - ifFatal(err) + Fatal(err) secondURL, err = getExpandedURL(secondURL, config.Aliases) - ifFatal(err) + Fatal(err) if isURLRecursive(secondURL) { console.Fatalf("Second URL cannot be recursive. %s\n", errInvalidArgument{}) } diff --git a/error.go b/error.go index 2d098e38..b3c5d1bb 100644 --- a/error.go +++ b/error.go @@ -1,3 +1,19 @@ +/* + * Minio Client (C) 2014, 2015 Minio, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package main import ( @@ -5,27 +21,41 @@ import ( "github.com/minio/minio/pkg/probe" ) -func ifFatal(err *probe.Error) { - switch err { - case nil: - // nothing to print - default: - if !globalDebugFlag { - console.Fatalln(err.ToError()) +// Fatal wrapper function which takes error and selectively prints stack frames if available on debug +func Fatal(err error) { + if err == nil { + return + } + switch e := err.(type) { + case *probe.Error: + if e == nil { + return } + if !globalDebugFlag { + console.Fatalln(e.ToError()) + } + console.Fatalln(err) + default: console.Fatalln(err) } } -func ifError(err *probe.Error) { - switch err { - case nil: - // nothing to print - default: +// Error synonymous with Fatal but doesn't exit on error != nil +func Error(err error) { + if err == nil { + return + } + switch e := err.(type) { + case *probe.Error: + if e == nil { + return + } if !globalDebugFlag { - console.Errorln(err.ToError()) + console.Errorln(e.ToError()) return } console.Errorln(err) + default: + console.Errorln(err) } } diff --git a/first-time.go b/first-time.go index 3644ac2f..a3b6abf7 100644 --- a/first-time.go +++ b/first-time.go @@ -111,14 +111,14 @@ func firstTimeRun() { console.Fatalf("Unable to create ‘mc’ config folder. %s\n", err) } config, err := newConfig() - ifFatal(err) + Fatal(err) err = writeConfig(config) - ifFatal(err) + Fatal(err) console.Infoln("Configuration written to [" + mustGetMcConfigPath() + "]. Please update your access credentials.") } if !isSessionDirExists() { err := createSessionDir() - ifFatal(err) + Fatal(err) } checkGolangVersion() } diff --git a/ls-main.go b/ls-main.go index 7b37fc70..34885274 100644 --- a/ls-main.go +++ b/ls-main.go @@ -83,10 +83,10 @@ func runListCmd(ctx *cli.Context) { config := mustGetMcConfig() for _, arg := range args { targetURL, err := getExpandedURL(arg, config.Aliases) - ifFatal(err) + Fatal(err) // if recursive strip off the "..." newTargetURL := stripRecursiveURL(targetURL) - ifFatal(doListCmd(newTargetURL, isURLRecursive(targetURL))) + Fatal(doListCmd(newTargetURL, isURLRecursive(targetURL))) } } diff --git a/ls.go b/ls.go index 5538222c..88bf5a09 100644 --- a/ls.go +++ b/ls.go @@ -79,11 +79,11 @@ func doList(clnt client.Client, recursive bool) *probe.Error { switch contentCh.Err.ToError().(type) { // handle this specifically for filesystem case client.ISBrokenSymlink: - ifError(contentCh.Err) + Error(contentCh.Err) continue } if os.IsNotExist(contentCh.Err.ToError()) || os.IsPermission(contentCh.Err.ToError()) { - ifError(contentCh.Err) + Error(contentCh.Err) continue } err = contentCh.Err diff --git a/main.go b/main.go index c315fdf5..fb46536b 100644 --- a/main.go +++ b/main.go @@ -38,7 +38,7 @@ func checkConfig() { // Ensures config file is sane { _, err := getMcConfig() - ifFatal(err) + Fatal(err) } } diff --git a/mb-main.go b/mb-main.go index 9605a23b..b9241411 100644 --- a/mb-main.go +++ b/mb-main.go @@ -60,8 +60,10 @@ func runMakeBucketCmd(ctx *cli.Context) { config := mustGetMcConfig() for _, arg := range ctx.Args() { targetURL, err := getExpandedURL(arg, config.Aliases) - ifFatal(err) - ifFatal(doMakeBucketCmd(targetURL)) + Fatal(err) + + err = doMakeBucketCmd(targetURL) + Fatal(err) console.Infoln("Bucket created successfully : " + targetURL) } } diff --git a/mirror-main.go b/mirror-main.go index c7c5215c..73040236 100644 --- a/mirror-main.go +++ b/mirror-main.go @@ -152,7 +152,7 @@ func doPrepareMirrorURLs(session *sessionV2, trapCh <-chan bool) { break } if sURLs.Error != nil { - ifError(sURLs.Error) + Error(sURLs.Error) break } if sURLs.isEmpty() { @@ -221,7 +221,7 @@ func doMirrorCmdSession(session *sessionV2) { session.Header.LastCopied = sURLs.SourceContent.Name } else { console.Println() - ifError(sURLs.Error) + Error(sURLs.Error) } case <-trapCh: // Receive interrupt notification. session.Close() diff --git a/mirror-url.go b/mirror-url.go index ce88564a..f1dd621f 100644 --- a/mirror-url.go +++ b/mirror-url.go @@ -57,7 +57,7 @@ func checkMirrorSyntax(ctx *cli.Context) { // extract URLs. URLs, err := args2URLs(ctx.Args()) - ifFatal(err) + Fatal(err) srcURL := URLs[0] tgtURLs := URLs[1:] @@ -66,7 +66,7 @@ func checkMirrorSyntax(ctx *cli.Context) { // Source cannot be a folder (except when recursive) if !isURLRecursive(srcURL) { _, srcContent, err := url2Stat(srcURL) - ifFatal(err) + Fatal(err) if !srcContent.Type.IsRegular() { if srcContent.Type.IsDir() { @@ -93,16 +93,16 @@ func checkMirrorSyntax(ctx *cli.Context) { } srcURL = stripRecursiveURL(srcURL) _, srcContent, err := url2Stat(srcURL) - ifFatal(err) + Fatal(err) if srcContent.Type.IsRegular() { // Ellipses is supported only for folders. - ifFatal(probe.New(errSourceIsNotDir{URL: srcURL})) + Fatal(probe.New(errSourceIsNotDir{URL: srcURL})) } for _, tgtURL := range tgtURLs { _, content, err := url2Stat(tgtURL) if err == nil { if !content.Type.IsDir() { - ifFatal(probe.New(errTargetIsNotDir{URL: tgtURL})) + Fatal(probe.New(errTargetIsNotDir{URL: tgtURL})) } } } @@ -165,7 +165,7 @@ func deltaSourceTargets(sourceClnt client.Client, targetClnts []client.Client) < if !targetTrie.Match(patricia.Prefix(matchName)) { sourceURLDelimited := sourceClnt.URL().String()[:strings.LastIndex(sourceClnt.URL().String(), string(sourceClnt.URL().Separator))+1] - newTargetURLParse := targetClnts[i].URL() + newTargetURLParse := *targetClnts[i].URL() newTargetURLParse.Path = filepath.Join(newTargetURLParse.Path, matchName) sourceContent.Size = sourceTrie.Get(patricia.Prefix(matchName)).(int64) sourceContent.Name = sourceURLDelimited + matchName diff --git a/pkg/client/s3/s3.go b/pkg/client/s3/s3.go index 01889afd..781a9c38 100644 --- a/pkg/client/s3/s3.go +++ b/pkg/client/s3/s3.go @@ -118,8 +118,11 @@ func (c *s3Client) PutObject(size int64, data io.Reader) *probe.Error { bucket, object := c.url2BucketAndObject() err := c.api.PutObject(bucket, object, "application/octet-stream", size, data) if err != nil { - if minio.ToErrorResponse(err).Code == "MethodNotAllowed" { - return probe.New(ObjectAlreadyExists{Object: object}) + errResponse := minio.ToErrorResponse(err) + if errResponse != nil { + if errResponse.Code == "MethodNotAllowed" { + return probe.New(ObjectAlreadyExists{Object: object}) + } } return probe.New(err) } diff --git a/session-main.go b/session-main.go index 351b7e32..6f11499a 100644 --- a/session-main.go +++ b/session-main.go @@ -85,7 +85,7 @@ func clearSession(sid string) { if sid == "all" { for _, sid := range getSessionIDs() { session, err := loadSessionV2(sid) - ifFatal(err) + Fatal(err) session.Delete() } return @@ -96,7 +96,7 @@ func clearSession(sid string) { } session, err := loadSessionV2(sid) - ifFatal(err) + Fatal(err) if session != nil { session.Delete() } @@ -119,13 +119,13 @@ func runSessionCmd(ctx *cli.Context) { cli.ShowCommandHelpAndExit(ctx, "session", 1) // last argument is exit code } if !isSessionDirExists() { - ifFatal(createSessionDir()) + Fatal(createSessionDir()) } switch strings.TrimSpace(ctx.Args().First()) { // list resumable sessions case "list": err := listSessions() - ifFatal(err) + Fatal(err) case "resume": if len(ctx.Args().Tail()) != 1 { cli.ShowCommandHelpAndExit(ctx, "session", 1) // last argument is exit code @@ -140,7 +140,7 @@ func runSessionCmd(ctx *cli.Context) { console.Fatalln(errInvalidSessionID{id: sid}) } s, err := loadSessionV2(sid) - ifFatal(err) + Fatal(err) // extra check for testing purposes if s == nil { return diff --git a/errors.go b/typed-errors.go similarity index 100% rename from errors.go rename to typed-errors.go diff --git a/update-main.go b/update-main.go index 0ee7723a..3cf0908d 100644 --- a/update-main.go +++ b/update-main.go @@ -104,7 +104,7 @@ func runUpdateCmd(ctx *cli.Context) { cli.ShowCommandHelpAndExit(ctx, "update", 1) // last argument is exit code } msg, err := doUpdateCheck() - ifFatal(err) + Fatal(err) // no msg do not print one if msg != "" { console.Infoln(msg)