Merge pull request #1287 from krishnasrinivas/rm-remove-force
Remove --force option from cp as url2stat() on s3 checks were slowing things down
This commit is contained in:
-23
@@ -34,29 +34,17 @@ import (
|
||||
"github.com/minio/minio-xl/pkg/probe"
|
||||
)
|
||||
|
||||
// cp specific flags.
|
||||
var (
|
||||
cpFlagForce = cli.BoolFlag{
|
||||
Name: "force",
|
||||
Usage: "Force overwrite of an existing target(s).",
|
||||
}
|
||||
)
|
||||
|
||||
// Copy command.
|
||||
var cpCmd = cli.Command{
|
||||
Name: "cp",
|
||||
Usage: "Copy one or more objects to a target.",
|
||||
Action: mainCopy,
|
||||
Flags: []cli.Flag{cpFlagForce},
|
||||
CustomHelpTemplate: `NAME:
|
||||
mc {{.Name}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
mc {{.Name}} [OPTIONS] SOURCE [SOURCE...] TARGET
|
||||
|
||||
OPTIONS:
|
||||
--force - Force overwrite of an existing target(s).
|
||||
|
||||
EXAMPLES:
|
||||
1. Copy a list of objects from local file system to Amazon S3 cloud storage.
|
||||
$ mc {{.Name}} Music/*.ogg https://s3.amazonaws.com/jukebox/
|
||||
@@ -78,10 +66,6 @@ EXAMPLES:
|
||||
`,
|
||||
}
|
||||
|
||||
var (
|
||||
cpIsForce = false // cp specific force flag set via command line
|
||||
)
|
||||
|
||||
// copyMessage container for file copy messages
|
||||
type copyMessage struct {
|
||||
Source string `json:"source"`
|
||||
@@ -181,9 +165,6 @@ func doPrepareCopyURLs(session *sessionV3, trapCh <-chan bool) {
|
||||
scanBar = scanBarFactory()
|
||||
}
|
||||
|
||||
// will be true if '--force' is provided on the command line.
|
||||
cpIsForce = session.Header.CommandBoolFlag.Value
|
||||
|
||||
URLsCh := prepareCopyURLs(sourceURLs, targetURL)
|
||||
done := false
|
||||
|
||||
@@ -351,10 +332,6 @@ func mainCopy(ctx *cli.Context) {
|
||||
fatalIf(probe.NewError(e), "Unable to get current working folder.")
|
||||
}
|
||||
|
||||
// If force flag is set save it with in session
|
||||
session.Header.CommandBoolFlag.Key = "force"
|
||||
session.Header.CommandBoolFlag.Value = ctx.Bool("force")
|
||||
|
||||
// extract URLs.
|
||||
var err *probe.Error
|
||||
session.Header.CommandArgs, err = args2URLs(ctx.Args())
|
||||
|
||||
@@ -247,11 +247,6 @@ func prepareCopyURLsTypeA(sourceURL string, targetURL string) copyURLs {
|
||||
return copyURLs{Error: errInvalidSource(sourceURL).Trace()}
|
||||
}
|
||||
|
||||
_, _, err = url2Stat(targetURL)
|
||||
if err == nil && !cpIsForce {
|
||||
return copyURLs{Error: errOverWriteNotAllowed(targetURL).Trace()}
|
||||
}
|
||||
|
||||
// All OK.. We can proceed. Type A
|
||||
return copyURLs{SourceContent: sourceContent, TargetContent: &client.Content{URL: *client.NewURL(targetURL)}}
|
||||
}
|
||||
@@ -344,12 +339,6 @@ func prepareCopyURLsTypeC(sourceURL, targetURL string) <-chan copyURLs {
|
||||
newTargetURL.Path = filepath.Join(newTargetURL.Path,
|
||||
strings.TrimPrefix(sourceContent.Content.URL.Path, url2Dir(sourceURL)))
|
||||
|
||||
// verify if destination exists, and cpIsForce is not set do not proceed.
|
||||
_, _, err := url2Stat(newTargetURL.String())
|
||||
if err == nil && !cpIsForce {
|
||||
copyURLsCh <- copyURLs{Error: errOverWriteNotAllowed(newTargetURL.String()).Trace()}
|
||||
return
|
||||
}
|
||||
copyURLsCh <- prepareCopyURLsTypeA(sourceContent.Content.URL.String(), newTargetURL.String())
|
||||
}
|
||||
}(sourceURL, targetURL, copyURLsCh)
|
||||
|
||||
Reference in New Issue
Block a user