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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user