mirror of
https://github.com/minio/mc.git
synced 2025-11-12 01:02:26 +03:00
Do not exit mirroring for cannot delete/overwrite errors (#2416)
mc used to show a warning messages during mirroring when it
detects a need to overwrite or remove a remote object but no
flag is specified. This commit efeaf2ee72
changed this behavior but this commit will restablish
the old behavior.
This commit is contained in:
@@ -578,7 +578,11 @@ func (mj *mirrorJob) mirror(ctx context.Context, cancelMirror context.CancelFunc
|
|||||||
case BrokenSymlink, TooManyLevelsSymlink, PathNotFound,
|
case BrokenSymlink, TooManyLevelsSymlink, PathNotFound,
|
||||||
PathInsufficientPermission, ObjectOnGlacier:
|
PathInsufficientPermission, ObjectOnGlacier:
|
||||||
continue
|
continue
|
||||||
|
case deleteNotAllowedErr, overwriteNotAllowedErr:
|
||||||
|
errorIf(err, "Unable to perform a mirror action")
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
return err.Trace()
|
return err.Trace()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -177,7 +177,6 @@ func deltaSourceTarget(sourceURL, targetURL string, isFake, isOverwrite, isRemov
|
|||||||
TgtSSEKey: tgtSSEKey,
|
TgtSSEKey: tgtSSEKey,
|
||||||
}
|
}
|
||||||
case differInSecond:
|
case differInSecond:
|
||||||
|
|
||||||
if !isRemove && !isFake {
|
if !isRemove && !isFake {
|
||||||
// Object removal not allowed if --remove is not set.
|
// Object removal not allowed if --remove is not set.
|
||||||
URLsCh <- URLs{
|
URLsCh <- URLs{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Minio Client (C) 2014, 2015 Minio, Inc.
|
* Minio Client (C) 2014, 2015, 2018 Minio, Inc.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -24,67 +24,109 @@ import (
|
|||||||
"github.com/minio/mc/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
type dummyErr error
|
||||||
errDummy = func() *probe.Error {
|
|
||||||
return probe.NewError(errors.New("")).Untrace()
|
|
||||||
}
|
|
||||||
|
|
||||||
errInvalidArgument = func() *probe.Error {
|
var errDummy = func() *probe.Error {
|
||||||
return probe.NewError(errors.New("Invalid arguments provided, please refer " + "`mc <command> -h` for relevant documentation.")).Untrace()
|
msg := ""
|
||||||
}
|
return probe.NewError(dummyErr(errors.New(msg))).Untrace()
|
||||||
|
}
|
||||||
|
|
||||||
errUnrecognizedDiffType = func(diff differType) *probe.Error {
|
type invalidArgumentErr error
|
||||||
return probe.NewError(errors.New("Unrecognized diffType: " + diff.String() + " provided.")).Untrace()
|
|
||||||
}
|
|
||||||
|
|
||||||
errInvalidAliasedURL = func(URL string) *probe.Error {
|
var errInvalidArgument = func() *probe.Error {
|
||||||
return probe.NewError(errors.New("Use `mc config host add mycloud " + URL + " ...` to add an alias. Use the alias for S3 operations.")).Untrace()
|
msg := "Invalid arguments provided, please refer " + "`mc <command> -h` for relevant documentation."
|
||||||
}
|
return probe.NewError(invalidArgumentErr(errors.New(msg))).Untrace()
|
||||||
|
}
|
||||||
|
|
||||||
errInvalidAlias = func(alias string) *probe.Error {
|
type unrecognizedDiffTypeErr error
|
||||||
return probe.NewError(errors.New("Alias `" + alias + "` should have alphanumeric characters such as [helloWorld0, hello_World0, ...]"))
|
|
||||||
}
|
|
||||||
|
|
||||||
errInvalidURL = func(URL string) *probe.Error {
|
var errUnrecognizedDiffType = func(diff differType) *probe.Error {
|
||||||
return probe.NewError(errors.New("URL `" + URL + "` for minio client should be of the form scheme://host[:port]/ without resource component."))
|
msg := "Unrecognized diffType: " + diff.String() + " provided."
|
||||||
}
|
return probe.NewError(unrecognizedDiffTypeErr(errors.New(msg))).Untrace()
|
||||||
|
}
|
||||||
|
|
||||||
errInvalidAPISignature = func(api, url string) *probe.Error {
|
type invalidAliasedURLErr error
|
||||||
|
|
||||||
|
var errInvalidAliasedURL = func(URL string) *probe.Error {
|
||||||
|
msg := "Use `mc config host add mycloud " + URL + " ...` to add an alias. Use the alias for S3 operations."
|
||||||
|
return probe.NewError(invalidAliasedURLErr(errors.New(msg))).Untrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
type invalidAliasErr error
|
||||||
|
|
||||||
|
var errInvalidAlias = func(alias string) *probe.Error {
|
||||||
|
msg := "Alias `" + alias + "` should have alphanumeric characters such as [helloWorld0, hello_World0, ...]"
|
||||||
|
return probe.NewError(invalidAliasErr(errors.New(msg)))
|
||||||
|
}
|
||||||
|
|
||||||
|
type invalidURLErr error
|
||||||
|
|
||||||
|
var errInvalidURL = func(URL string) *probe.Error {
|
||||||
|
msg := "URL `" + URL + "` for minio client should be of the form scheme://host[:port]/ without resource component."
|
||||||
|
return probe.NewError(invalidURLErr(errors.New(msg)))
|
||||||
|
}
|
||||||
|
|
||||||
|
type invalidAPISignatureErr error
|
||||||
|
|
||||||
|
var errInvalidAPISignature = func(api, url string) *probe.Error {
|
||||||
msg := fmt.Sprintf(
|
msg := fmt.Sprintf(
|
||||||
"Unrecognized API signature %s for host %s. Valid options are `[%s]`",
|
"Unrecognized API signature %s for host %s. Valid options are `[%s]`",
|
||||||
api, url, strings.Join(validAPIs, ", "))
|
api, url, strings.Join(validAPIs, ", "))
|
||||||
return probe.NewError(errors.New(msg))
|
return probe.NewError(invalidAPISignatureErr(errors.New(msg)))
|
||||||
}
|
}
|
||||||
|
|
||||||
errNoMatchingHost = func(URL string) *probe.Error {
|
type noMatchingHostErr error
|
||||||
return probe.NewError(errors.New("No matching host found for the given URL `" + URL + "`.")).Untrace()
|
|
||||||
}
|
|
||||||
|
|
||||||
errInvalidSource = func(URL string) *probe.Error {
|
var errNoMatchingHost = func(URL string) *probe.Error {
|
||||||
return probe.NewError(errors.New("Invalid source `" + URL + "`.")).Untrace()
|
msg := "No matching host found for the given URL `" + URL + "`."
|
||||||
}
|
return probe.NewError(noMatchingHostErr(errors.New(msg))).Untrace()
|
||||||
|
}
|
||||||
|
|
||||||
errInvalidTarget = func(URL string) *probe.Error {
|
type invalidSourceErr error
|
||||||
return probe.NewError(errors.New("Invalid target `" + URL + "`.")).Untrace()
|
|
||||||
}
|
|
||||||
|
|
||||||
errOverWriteNotAllowed = func(URL string) *probe.Error {
|
var errInvalidSource = func(URL string) *probe.Error {
|
||||||
return probe.NewError(errors.New("Overwrite not allowed for `" + URL + "`. Use `--overwrite` to override this behavior."))
|
msg := "Invalid source `" + URL + "`."
|
||||||
}
|
return probe.NewError(invalidSourceErr(errors.New(msg))).Untrace()
|
||||||
|
}
|
||||||
|
|
||||||
errDeleteNotAllowed = func(URL string) *probe.Error {
|
type invalidTargetErr error
|
||||||
return probe.NewError(errors.New("Delete not allowed for `" + URL + "`. Use `--remove` to override this behavior."))
|
|
||||||
}
|
|
||||||
|
|
||||||
errSourceIsDir = func(URL string) *probe.Error {
|
var errInvalidTarget = func(URL string) *probe.Error {
|
||||||
return probe.NewError(errors.New("Source `" + URL + "` is a folder.")).Untrace()
|
msg := "Invalid target `" + URL + "`."
|
||||||
}
|
return probe.NewError(invalidTargetErr(errors.New(msg))).Untrace()
|
||||||
|
}
|
||||||
|
|
||||||
errSourceTargetSame = func(URL string) *probe.Error {
|
type overwriteNotAllowedErr error
|
||||||
return probe.NewError(errors.New("Source and target URL can not be same : " + URL)).Untrace()
|
|
||||||
}
|
|
||||||
|
|
||||||
errBucketNotSpecified = func() *probe.Error {
|
var errOverWriteNotAllowed = func(URL string) *probe.Error {
|
||||||
return probe.NewError(errors.New("This operation requires a " + "bucket to be specified.")).Untrace()
|
msg := "Overwrite not allowed for `" + URL + "`. Use `--overwrite` to override this behavior."
|
||||||
}
|
return probe.NewError(overwriteNotAllowedErr(errors.New(msg)))
|
||||||
)
|
}
|
||||||
|
|
||||||
|
type deleteNotAllowedErr error
|
||||||
|
|
||||||
|
var errDeleteNotAllowed = func(URL string) *probe.Error {
|
||||||
|
msg := "Delete not allowed for `" + URL + "`. Use `--remove` to override this behavior."
|
||||||
|
return probe.NewError(deleteNotAllowedErr(errors.New(msg)))
|
||||||
|
}
|
||||||
|
|
||||||
|
type sourceIsDirErr error
|
||||||
|
|
||||||
|
var errSourceIsDir = func(URL string) *probe.Error {
|
||||||
|
msg := "Source `" + URL + "` is a folder."
|
||||||
|
return probe.NewError(sourceIsDirErr(errors.New(msg))).Untrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
type sourceTargetSameErr error
|
||||||
|
|
||||||
|
var errSourceTargetSame = func(URL string) *probe.Error {
|
||||||
|
msg := "Source and target URL can not be same : " + URL
|
||||||
|
return probe.NewError(sourceTargetSameErr(errors.New(msg))).Untrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
type bucketNotSpecifiedErr error
|
||||||
|
|
||||||
|
var errBucketNotSpecified = func() *probe.Error {
|
||||||
|
msg := "This operation requires a " + "bucket to be specified."
|
||||||
|
return probe.NewError(bucketNotSpecifiedErr(errors.New(msg))).Untrace()
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user