From dc430afe07f5ce09b06055477cc5370e50e2f45b Mon Sep 17 00:00:00 2001 From: Poorna Krishnamoorthy Date: Thu, 12 Mar 2020 19:03:22 -0700 Subject: [PATCH] mc cp: Fix prefix handling in TypeC for copy from filesystem to objectstorage. Avoid prefixing dirname to file on target side when doing a `mc cp /tmp/dir myminio/bucket --r` to make `mc mirror` and `mc cp` behavior consistent --- cmd/cp-url.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/cp-url.go b/cmd/cp-url.go index 86e72f7a..47210f77 100644 --- a/cmd/cp-url.go +++ b/cmd/cp-url.go @@ -191,6 +191,11 @@ func makeCopyContentTypeC(sourceAlias string, sourceURL clientURL, sourceContent newSourceSuffix := filepath.ToSlash(newSourceURL.Path) if pathSeparatorIndex > 1 { sourcePrefix := filepath.ToSlash(sourceURL.Path[:pathSeparatorIndex]) + // do not preserve unix cp behavior when copying from filesytem to + // objectstore. + if sourceAlias == "" && targetAlias != "" { + sourcePrefix = sourceURL.Path + } newSourceSuffix = strings.TrimPrefix(newSourceSuffix, sourcePrefix) } newTargetURL := urlJoinPath(targetURL, newSourceSuffix)