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
This commit is contained in:
Poorna Krishnamoorthy
2020-03-15 14:31:21 -07:00
parent 1092f6932f
commit dc430afe07
+5
View File
@@ -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)