From 511416b0f9a5e6bed377dc14420e08c89c1e6dbf Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sun, 26 Apr 2015 16:02:57 -0700 Subject: [PATCH] Recursive copy with prefix works now fixes - #496 --- cmd-options.go | 4 +++- copy.go | 1 + pkg/client/s3/bucket_list.go | 6 +----- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cmd-options.go b/cmd-options.go index 495a5146..454a26e5 100644 --- a/cmd-options.go +++ b/cmd-options.go @@ -58,7 +58,7 @@ EXAMPLES: } catCmd = cli.Command{ Name: "cat", - Usage: "Concantenate an object to standard output", + Usage: "Concantenate objects or files to standard output", Action: runCatCmd, CustomHelpTemplate: `NAME: mc {{.Name}} - {{.Usage}} @@ -80,6 +80,8 @@ EXAMPLES: 2. Concantenate a file from local filesystem to standard output. $ mc {{.Name}} khitomer-accords.txt + 3. Concantenate multiple files from local filesystem to standard output. + $ mc {{.Name}} *.txt > newfile.txt `, } cpCmd = cli.Command{ diff --git a/copy.go b/copy.go index 4a48ac8a..8ec2c176 100644 --- a/copy.go +++ b/copy.go @@ -59,6 +59,7 @@ func doCopySingleSourceRecursive(methods clientMethods, sourceURL, targetURL str if itemCh.Err != nil { continue } + sourceURL = strings.TrimSuffix(sourceURL, getObjectKey(sourceURL)) newSourceURL := strings.TrimSuffix(sourceURL, pathSeparator) + pathSeparator + itemCh.Item.Name newTargetURL := strings.TrimSuffix(targetURL, pathSeparator) + pathSeparator + itemCh.Item.Name if err := doCopySingleSource(methods, newSourceURL, newTargetURL, sourceConfig, targetConfig); err != nil { diff --git a/pkg/client/s3/bucket_list.go b/pkg/client/s3/bucket_list.go index 35f21f4a..fe6a267e 100644 --- a/pkg/client/s3/bucket_list.go +++ b/pkg/client/s3/bucket_list.go @@ -24,8 +24,6 @@ import ( "io" "net/http" "net/url" - "path/filepath" - "strings" "github.com/minio-io/mc/pkg/client" "github.com/minio-io/minio/pkg/iodine" @@ -126,9 +124,7 @@ func (c *s3Client) filterItems(startAt, marker, prefix, delimiter string, conten return nil, marker, iodine.New(client.UnexpectedError{Err: errors.New(msg)}, nil) } item := new(client.Item) - // TODO (y4m4) - this is temporary, fix this after passing down proper delimiters - // for now using filepath.Separator - item.Name = strings.TrimPrefix(it.Key, filepath.Clean(prefix)+string(filepath.Separator)) + item.Name = it.Key item.Time = it.LastModified item.Size = it.Size item.FileType = 0