mirror of
https://github.com/minio/mc.git
synced 2025-11-13 12:22:45 +03:00
Rename ifFatal and ifError as Fatal, Error
This commit is contained in:
@@ -64,14 +64,14 @@ func runAccessCmd(ctx *cli.Context) {
|
|||||||
config := mustGetMcConfig()
|
config := mustGetMcConfig()
|
||||||
acl := bucketACL(ctx.Args().First())
|
acl := bucketACL(ctx.Args().First())
|
||||||
if !acl.isValidBucketACL() {
|
if !acl.isValidBucketACL() {
|
||||||
ifFatal(probe.New(errInvalidACL{acl: acl.String()}))
|
Fatal(probe.New(errInvalidACL{acl: acl.String()}))
|
||||||
}
|
}
|
||||||
for _, arg := range ctx.Args().Tail() {
|
for _, arg := range ctx.Args().Tail() {
|
||||||
targetURL, err := getExpandedURL(arg, config.Aliases)
|
targetURL, err := getExpandedURL(arg, config.Aliases)
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
|
|
||||||
err = doUpdateAccessCmd(targetURL, acl)
|
err = doUpdateAccessCmd(targetURL, acl)
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ func runCatCmd(ctx *cli.Context) {
|
|||||||
// Convert arguments to URLs: expand alias, fix format...
|
// Convert arguments to URLs: expand alias, fix format...
|
||||||
for _, arg := range ctx.Args() {
|
for _, arg := range ctx.Args() {
|
||||||
sourceURL, err := getExpandedURL(arg, config.Aliases)
|
sourceURL, err := getExpandedURL(arg, config.Aliases)
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
ifFatal(doCatCmd(sourceURL))
|
Fatal(doCatCmd(sourceURL))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ func runConfigCmd(ctx *cli.Context) {
|
|||||||
console.Fatalf("Incorrect number of arguments, please read \"mc config help\". %s", errInvalidArgument{})
|
console.Fatalf("Incorrect number of arguments, please read \"mc config help\". %s", errInvalidArgument{})
|
||||||
}
|
}
|
||||||
msg, err := doConfig(arg, tailArgs)
|
msg, err := doConfig(arg, tailArgs)
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
console.Infoln(msg)
|
console.Infoln(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
16
config.go
16
config.go
@@ -66,7 +66,7 @@ func getMcConfigDir() (string, *probe.Error) {
|
|||||||
// mustGetMcConfigDir - construct minio client config folder or fail
|
// mustGetMcConfigDir - construct minio client config folder or fail
|
||||||
func mustGetMcConfigDir() (configDir string) {
|
func mustGetMcConfigDir() (configDir string) {
|
||||||
configDir, err := getMcConfigDir()
|
configDir, err := getMcConfigDir()
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
return configDir
|
return configDir
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ func getMcConfigPath() (string, *probe.Error) {
|
|||||||
// mustGetMcConfigPath - similar to getMcConfigPath, ignores errors
|
// mustGetMcConfigPath - similar to getMcConfigPath, ignores errors
|
||||||
func mustGetMcConfigPath() string {
|
func mustGetMcConfigPath() string {
|
||||||
path, err := getMcConfigPath()
|
path, err := getMcConfigPath()
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,7 +132,7 @@ func getMcConfig() (*configV1, *probe.Error) {
|
|||||||
// mustGetMcConfig - reads configuration file and returns configs, exits on error
|
// mustGetMcConfig - reads configuration file and returns configs, exits on error
|
||||||
func mustGetMcConfig() *configV1 {
|
func mustGetMcConfig() *configV1 {
|
||||||
config, err := getMcConfig()
|
config, err := getMcConfig()
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,9 +175,9 @@ func migrateConfigV1ToV101() {
|
|||||||
}
|
}
|
||||||
conf := newConfigV1()
|
conf := newConfigV1()
|
||||||
config, err := quick.New(conf)
|
config, err := quick.New(conf)
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
err = config.Load(mustGetMcConfigPath())
|
err = config.Load(mustGetMcConfigPath())
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
|
|
||||||
conf = config.Data().(*configV1)
|
conf = config.Data().(*configV1)
|
||||||
// version is the same return
|
// version is the same return
|
||||||
@@ -206,9 +206,9 @@ func migrateConfigV1ToV101() {
|
|||||||
|
|
||||||
{
|
{
|
||||||
newConfig, err := quick.New(conf)
|
newConfig, err := quick.New(conf)
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
err = newConfig.Save(mustGetMcConfigPath())
|
err = newConfig.Save(mustGetMcConfigPath())
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
console.Infof("Successfully migrated %s from version: %s to version: %s\n", mustGetMcConfigPath(), mcPreviousConfigVersion, mcCurrentConfigVersion)
|
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
|
// mustNewConfig instantiates a new config handler, exists upon error
|
||||||
func mustNewConfig() quick.Config {
|
func mustNewConfig() quick.Config {
|
||||||
config, err := newConfig()
|
config, err := newConfig()
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ func doPrepareCopyURLs(session *sessionV2, trapCh <-chan bool) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
if cpURLs.Error != nil {
|
if cpURLs.Error != nil {
|
||||||
ifError(cpURLs.Error)
|
Error(cpURLs.Error)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ func doCopyCmdSession(session *sessionV2) {
|
|||||||
session.Header.LastCopied = cpURLs.SourceContent.Name
|
session.Header.LastCopied = cpURLs.SourceContent.Name
|
||||||
} else {
|
} else {
|
||||||
console.Println()
|
console.Println()
|
||||||
ifError(cpURLs.Error)
|
Error(cpURLs.Error)
|
||||||
}
|
}
|
||||||
case <-trapCh: // Receive interrupt notification.
|
case <-trapCh: // Receive interrupt notification.
|
||||||
session.Close()
|
session.Close()
|
||||||
|
|||||||
26
cp-url.go
26
cp-url.go
@@ -108,12 +108,12 @@ func checkCopySyntaxTypeA(srcURLs []string, tgtURL string) {
|
|||||||
}
|
}
|
||||||
srcURL := srcURLs[0]
|
srcURL := srcURLs[0]
|
||||||
_, srcContent, err := url2Stat(srcURL)
|
_, srcContent, err := url2Stat(srcURL)
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
if srcContent.Type.IsDir() {
|
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{})
|
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() {
|
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]
|
srcURL := srcURLs[0]
|
||||||
_, srcContent, err := url2Stat(srcURL)
|
_, srcContent, err := url2Stat(srcURL)
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
if srcContent.Type.IsDir() {
|
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{})
|
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() {
|
if !srcContent.Type.IsRegular() {
|
||||||
ifFatal(probe.New(errSourceIsNotFile{URL: srcURL}))
|
Fatal(probe.New(errSourceIsNotFile{URL: srcURL}))
|
||||||
}
|
}
|
||||||
|
|
||||||
_, tgtContent, err := url2Stat(tgtURL)
|
_, tgtContent, err := url2Stat(tgtURL)
|
||||||
// Target exist?.
|
// Target exist?.
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if !tgtContent.Type.IsDir() {
|
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 := srcURLs[0]
|
||||||
srcURL = stripRecursiveURL(srcURL)
|
srcURL = stripRecursiveURL(srcURL)
|
||||||
_, srcContent, err := url2Stat(srcURL)
|
_, srcContent, err := url2Stat(srcURL)
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
|
|
||||||
if srcContent.Type.IsRegular() { // Ellipses is supported only for folders.
|
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)
|
_, tgtContent, err := url2Stat(tgtURL)
|
||||||
// Target exist?.
|
// Target exist?.
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if !tgtContent.Type.IsDir() {
|
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) {
|
if isURLRecursive(srcURL) {
|
||||||
srcURL = stripRecursiveURL(srcURL)
|
srcURL = stripRecursiveURL(srcURL)
|
||||||
_, srcContent, err := url2Stat(srcURL)
|
_, srcContent, err := url2Stat(srcURL)
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
if !srcContent.Type.IsDir() { // Ellipses is supported only for folders.
|
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.
|
} else { // Regular URL.
|
||||||
_, srcContent, err := url2Stat(srcURL)
|
_, srcContent, err := url2Stat(srcURL)
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
if srcContent.Type.IsDir() {
|
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{})
|
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() {
|
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?.
|
// Target exist?.
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if !tgtContent.Type.IsDir() {
|
if !tgtContent.Type.IsDir() {
|
||||||
ifFatal(probe.New(errTargetIsNotDir{URL: tgtURL}))
|
Fatal(probe.New(errTargetIsNotDir{URL: tgtURL}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,9 +63,9 @@ func runDiffCmd(ctx *cli.Context) {
|
|||||||
|
|
||||||
var err *probe.Error
|
var err *probe.Error
|
||||||
firstURL, err = getExpandedURL(firstURL, config.Aliases)
|
firstURL, err = getExpandedURL(firstURL, config.Aliases)
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
secondURL, err = getExpandedURL(secondURL, config.Aliases)
|
secondURL, err = getExpandedURL(secondURL, config.Aliases)
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
if isURLRecursive(secondURL) {
|
if isURLRecursive(secondURL) {
|
||||||
console.Fatalf("Second URL cannot be recursive. %s\n", errInvalidArgument{})
|
console.Fatalf("Second URL cannot be recursive. %s\n", errInvalidArgument{})
|
||||||
}
|
}
|
||||||
|
|||||||
56
error.go
56
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -5,27 +21,41 @@ import (
|
|||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/minio/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ifFatal(err *probe.Error) {
|
// Fatal wrapper function which takes error and selectively prints stack frames if available on debug
|
||||||
switch err {
|
func Fatal(err error) {
|
||||||
case nil:
|
if err == nil {
|
||||||
// nothing to print
|
return
|
||||||
default:
|
}
|
||||||
if !globalDebugFlag {
|
switch e := err.(type) {
|
||||||
console.Fatalln(err.ToError())
|
case *probe.Error:
|
||||||
|
if e == nil {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
if !globalDebugFlag {
|
||||||
|
console.Fatalln(e.ToError())
|
||||||
|
}
|
||||||
|
console.Fatalln(err)
|
||||||
|
default:
|
||||||
console.Fatalln(err)
|
console.Fatalln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ifError(err *probe.Error) {
|
// Error synonymous with Fatal but doesn't exit on error != nil
|
||||||
switch err {
|
func Error(err error) {
|
||||||
case nil:
|
if err == nil {
|
||||||
// nothing to print
|
return
|
||||||
default:
|
}
|
||||||
|
switch e := err.(type) {
|
||||||
|
case *probe.Error:
|
||||||
|
if e == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
if !globalDebugFlag {
|
if !globalDebugFlag {
|
||||||
console.Errorln(err.ToError())
|
console.Errorln(e.ToError())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.Errorln(err)
|
console.Errorln(err)
|
||||||
|
default:
|
||||||
|
console.Errorln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,14 +111,14 @@ func firstTimeRun() {
|
|||||||
console.Fatalf("Unable to create ‘mc’ config folder. %s\n", err)
|
console.Fatalf("Unable to create ‘mc’ config folder. %s\n", err)
|
||||||
}
|
}
|
||||||
config, err := newConfig()
|
config, err := newConfig()
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
err = writeConfig(config)
|
err = writeConfig(config)
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
console.Infoln("Configuration written to [" + mustGetMcConfigPath() + "]. Please update your access credentials.")
|
console.Infoln("Configuration written to [" + mustGetMcConfigPath() + "]. Please update your access credentials.")
|
||||||
}
|
}
|
||||||
if !isSessionDirExists() {
|
if !isSessionDirExists() {
|
||||||
err := createSessionDir()
|
err := createSessionDir()
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
}
|
}
|
||||||
checkGolangVersion()
|
checkGolangVersion()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,10 +83,10 @@ func runListCmd(ctx *cli.Context) {
|
|||||||
config := mustGetMcConfig()
|
config := mustGetMcConfig()
|
||||||
for _, arg := range args {
|
for _, arg := range args {
|
||||||
targetURL, err := getExpandedURL(arg, config.Aliases)
|
targetURL, err := getExpandedURL(arg, config.Aliases)
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
// if recursive strip off the "..."
|
// if recursive strip off the "..."
|
||||||
newTargetURL := stripRecursiveURL(targetURL)
|
newTargetURL := stripRecursiveURL(targetURL)
|
||||||
ifFatal(doListCmd(newTargetURL, isURLRecursive(targetURL)))
|
Fatal(doListCmd(newTargetURL, isURLRecursive(targetURL)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
ls.go
4
ls.go
@@ -79,11 +79,11 @@ func doList(clnt client.Client, recursive bool) *probe.Error {
|
|||||||
switch contentCh.Err.ToError().(type) {
|
switch contentCh.Err.ToError().(type) {
|
||||||
// handle this specifically for filesystem
|
// handle this specifically for filesystem
|
||||||
case client.ISBrokenSymlink:
|
case client.ISBrokenSymlink:
|
||||||
ifError(contentCh.Err)
|
Error(contentCh.Err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if os.IsNotExist(contentCh.Err.ToError()) || os.IsPermission(contentCh.Err.ToError()) {
|
if os.IsNotExist(contentCh.Err.ToError()) || os.IsPermission(contentCh.Err.ToError()) {
|
||||||
ifError(contentCh.Err)
|
Error(contentCh.Err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
err = contentCh.Err
|
err = contentCh.Err
|
||||||
|
|||||||
2
main.go
2
main.go
@@ -38,7 +38,7 @@ func checkConfig() {
|
|||||||
// Ensures config file is sane
|
// Ensures config file is sane
|
||||||
{
|
{
|
||||||
_, err := getMcConfig()
|
_, err := getMcConfig()
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,8 +60,10 @@ func runMakeBucketCmd(ctx *cli.Context) {
|
|||||||
config := mustGetMcConfig()
|
config := mustGetMcConfig()
|
||||||
for _, arg := range ctx.Args() {
|
for _, arg := range ctx.Args() {
|
||||||
targetURL, err := getExpandedURL(arg, config.Aliases)
|
targetURL, err := getExpandedURL(arg, config.Aliases)
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
ifFatal(doMakeBucketCmd(targetURL))
|
|
||||||
|
err = doMakeBucketCmd(targetURL)
|
||||||
|
Fatal(err)
|
||||||
console.Infoln("Bucket created successfully : " + targetURL)
|
console.Infoln("Bucket created successfully : " + targetURL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ func doPrepareMirrorURLs(session *sessionV2, trapCh <-chan bool) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
if sURLs.Error != nil {
|
if sURLs.Error != nil {
|
||||||
ifError(sURLs.Error)
|
Error(sURLs.Error)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if sURLs.isEmpty() {
|
if sURLs.isEmpty() {
|
||||||
@@ -221,7 +221,7 @@ func doMirrorCmdSession(session *sessionV2) {
|
|||||||
session.Header.LastCopied = sURLs.SourceContent.Name
|
session.Header.LastCopied = sURLs.SourceContent.Name
|
||||||
} else {
|
} else {
|
||||||
console.Println()
|
console.Println()
|
||||||
ifError(sURLs.Error)
|
Error(sURLs.Error)
|
||||||
}
|
}
|
||||||
case <-trapCh: // Receive interrupt notification.
|
case <-trapCh: // Receive interrupt notification.
|
||||||
session.Close()
|
session.Close()
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ func checkMirrorSyntax(ctx *cli.Context) {
|
|||||||
|
|
||||||
// extract URLs.
|
// extract URLs.
|
||||||
URLs, err := args2URLs(ctx.Args())
|
URLs, err := args2URLs(ctx.Args())
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
|
|
||||||
srcURL := URLs[0]
|
srcURL := URLs[0]
|
||||||
tgtURLs := URLs[1:]
|
tgtURLs := URLs[1:]
|
||||||
@@ -66,7 +66,7 @@ func checkMirrorSyntax(ctx *cli.Context) {
|
|||||||
// Source cannot be a folder (except when recursive)
|
// Source cannot be a folder (except when recursive)
|
||||||
if !isURLRecursive(srcURL) {
|
if !isURLRecursive(srcURL) {
|
||||||
_, srcContent, err := url2Stat(srcURL)
|
_, srcContent, err := url2Stat(srcURL)
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
|
|
||||||
if !srcContent.Type.IsRegular() {
|
if !srcContent.Type.IsRegular() {
|
||||||
if srcContent.Type.IsDir() {
|
if srcContent.Type.IsDir() {
|
||||||
@@ -93,16 +93,16 @@ func checkMirrorSyntax(ctx *cli.Context) {
|
|||||||
}
|
}
|
||||||
srcURL = stripRecursiveURL(srcURL)
|
srcURL = stripRecursiveURL(srcURL)
|
||||||
_, srcContent, err := url2Stat(srcURL)
|
_, srcContent, err := url2Stat(srcURL)
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
|
|
||||||
if srcContent.Type.IsRegular() { // Ellipses is supported only for folders.
|
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 {
|
for _, tgtURL := range tgtURLs {
|
||||||
_, content, err := url2Stat(tgtURL)
|
_, content, err := url2Stat(tgtURL)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if !content.Type.IsDir() {
|
if !content.Type.IsDir() {
|
||||||
ifFatal(probe.New(errTargetIsNotDir{URL: tgtURL}))
|
Fatal(probe.New(errTargetIsNotDir{URL: tgtURL}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,8 +118,11 @@ func (c *s3Client) PutObject(size int64, data io.Reader) *probe.Error {
|
|||||||
bucket, object := c.url2BucketAndObject()
|
bucket, object := c.url2BucketAndObject()
|
||||||
err := c.api.PutObject(bucket, object, "application/octet-stream", size, data)
|
err := c.api.PutObject(bucket, object, "application/octet-stream", size, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if minio.ToErrorResponse(err).Code == "MethodNotAllowed" {
|
errResponse := minio.ToErrorResponse(err)
|
||||||
return probe.New(ObjectAlreadyExists{Object: object})
|
if errResponse != nil {
|
||||||
|
if errResponse.Code == "MethodNotAllowed" {
|
||||||
|
return probe.New(ObjectAlreadyExists{Object: object})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return probe.New(err)
|
return probe.New(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ func clearSession(sid string) {
|
|||||||
if sid == "all" {
|
if sid == "all" {
|
||||||
for _, sid := range getSessionIDs() {
|
for _, sid := range getSessionIDs() {
|
||||||
session, err := loadSessionV2(sid)
|
session, err := loadSessionV2(sid)
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
session.Delete()
|
session.Delete()
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@@ -96,7 +96,7 @@ func clearSession(sid string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
session, err := loadSessionV2(sid)
|
session, err := loadSessionV2(sid)
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
if session != nil {
|
if session != nil {
|
||||||
session.Delete()
|
session.Delete()
|
||||||
}
|
}
|
||||||
@@ -119,13 +119,13 @@ func runSessionCmd(ctx *cli.Context) {
|
|||||||
cli.ShowCommandHelpAndExit(ctx, "session", 1) // last argument is exit code
|
cli.ShowCommandHelpAndExit(ctx, "session", 1) // last argument is exit code
|
||||||
}
|
}
|
||||||
if !isSessionDirExists() {
|
if !isSessionDirExists() {
|
||||||
ifFatal(createSessionDir())
|
Fatal(createSessionDir())
|
||||||
}
|
}
|
||||||
switch strings.TrimSpace(ctx.Args().First()) {
|
switch strings.TrimSpace(ctx.Args().First()) {
|
||||||
// list resumable sessions
|
// list resumable sessions
|
||||||
case "list":
|
case "list":
|
||||||
err := listSessions()
|
err := listSessions()
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
case "resume":
|
case "resume":
|
||||||
if len(ctx.Args().Tail()) != 1 {
|
if len(ctx.Args().Tail()) != 1 {
|
||||||
cli.ShowCommandHelpAndExit(ctx, "session", 1) // last argument is exit code
|
cli.ShowCommandHelpAndExit(ctx, "session", 1) // last argument is exit code
|
||||||
@@ -140,7 +140,7 @@ func runSessionCmd(ctx *cli.Context) {
|
|||||||
console.Fatalln(errInvalidSessionID{id: sid})
|
console.Fatalln(errInvalidSessionID{id: sid})
|
||||||
}
|
}
|
||||||
s, err := loadSessionV2(sid)
|
s, err := loadSessionV2(sid)
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
// extra check for testing purposes
|
// extra check for testing purposes
|
||||||
if s == nil {
|
if s == nil {
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ func runUpdateCmd(ctx *cli.Context) {
|
|||||||
cli.ShowCommandHelpAndExit(ctx, "update", 1) // last argument is exit code
|
cli.ShowCommandHelpAndExit(ctx, "update", 1) // last argument is exit code
|
||||||
}
|
}
|
||||||
msg, err := doUpdateCheck()
|
msg, err := doUpdateCheck()
|
||||||
ifFatal(err)
|
Fatal(err)
|
||||||
// no msg do not print one
|
// no msg do not print one
|
||||||
if msg != "" {
|
if msg != "" {
|
||||||
console.Infoln(msg)
|
console.Infoln(msg)
|
||||||
|
|||||||
Reference in New Issue
Block a user