From dc4b903be980318d62fa4eea395069de5809165f Mon Sep 17 00:00:00 2001 From: Krishna Srinivas Date: Thu, 12 Nov 2015 19:13:14 -0800 Subject: [PATCH] Remove --force option from cp as url2stat() on s3 checks were slowing things down --- cp-main.go | 23 ----------------------- cp-url.go | 11 ----------- 2 files changed, 34 deletions(-) diff --git a/cp-main.go b/cp-main.go index e85b6b5e..192b42bd 100644 --- a/cp-main.go +++ b/cp-main.go @@ -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()) diff --git a/cp-url.go b/cp-url.go index ff8ec079..afc304a9 100644 --- a/cp-url.go +++ b/cp-url.go @@ -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)