mirror of
https://github.com/minio/minio.git
synced 2025-02-04 10:26:01 -05:00
copyObject: Be case sensitive for windows only server. (#3766)
For case sensitive platforms we should honor case. Fixes #3765 ``` 1) python s3cmd -c s3cfg_localminio put logo.png s3://testbucket/xyz/etc2/logo.PNG 2) python s3cmd -c s3cfg_localminio ls s3://testbucket/xyz/etc2/ 2017-02-18 10:58 22059 s3://testbucket/xyz/etc2/logo.PNG 3) python s3cmd -c s3cfg_localminio cp s3://testbucket/xyz/etc2/logo.PNG s3://testbucket/xyz/etc2/logo.png remote copy: 's3://testbucket/xyz/etc2/logo.PNG' -> 's3://testbucket/xyz/etc2/logo.png' 4) python s3cmd -c s3cfg_localminio ls s3://testbucket/xyz/etc2/ 2017-02-18 10:58 22059 s3://testbucket/xyz/etc2/logo.PNG 2017-02-18 11:10 22059 s3://testbucket/xyz/etc2/logo.png ```
This commit is contained in:
parent
54a18592e9
commit
7ea1de8245
@ -26,7 +26,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/minio/minio/pkg/disk"
|
"github.com/minio/minio/pkg/disk"
|
||||||
@ -367,7 +366,7 @@ func (fs fsObjects) CopyObject(srcBucket, srcObject, dstBucket, dstObject string
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if this request is only metadata update.
|
// Check if this request is only metadata update.
|
||||||
cpMetadataOnly := strings.EqualFold(pathJoin(srcBucket, srcObject), pathJoin(dstBucket, dstObject))
|
cpMetadataOnly := isStringEqual(pathJoin(srcBucket, srcObject), pathJoin(dstBucket, dstObject))
|
||||||
if cpMetadataOnly {
|
if cpMetadataOnly {
|
||||||
fsMetaPath := pathJoin(fs.fsPath, minioMetaBucket, bucketMetaPrefix, srcBucket, srcObject, fsMetaJSONFile)
|
fsMetaPath := pathJoin(fs.fsPath, minioMetaBucket, bucketMetaPrefix, srcBucket, srcObject, fsMetaJSONFile)
|
||||||
var wlk *lock.LockedFile
|
var wlk *lock.LockedFile
|
||||||
|
@ -164,7 +164,7 @@ func getCompleteMultipartMD5(parts []completePart) (string, error) {
|
|||||||
// For example on windows since its case insensitive we are supposed
|
// For example on windows since its case insensitive we are supposed
|
||||||
// to do case insensitive checks.
|
// to do case insensitive checks.
|
||||||
func hasPrefix(s string, prefix string) bool {
|
func hasPrefix(s string, prefix string) bool {
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == globalWindowsOSName {
|
||||||
return strings.HasPrefix(strings.ToLower(s), strings.ToLower(prefix))
|
return strings.HasPrefix(strings.ToLower(s), strings.ToLower(prefix))
|
||||||
}
|
}
|
||||||
return strings.HasPrefix(s, prefix)
|
return strings.HasPrefix(s, prefix)
|
||||||
@ -174,12 +174,20 @@ func hasPrefix(s string, prefix string) bool {
|
|||||||
// For example on windows since its case insensitive we are supposed
|
// For example on windows since its case insensitive we are supposed
|
||||||
// to do case insensitive checks.
|
// to do case insensitive checks.
|
||||||
func hasSuffix(s string, suffix string) bool {
|
func hasSuffix(s string, suffix string) bool {
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == globalWindowsOSName {
|
||||||
return strings.HasSuffix(strings.ToLower(s), strings.ToLower(suffix))
|
return strings.HasSuffix(strings.ToLower(s), strings.ToLower(suffix))
|
||||||
}
|
}
|
||||||
return strings.HasSuffix(s, suffix)
|
return strings.HasSuffix(s, suffix)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validates if two strings are equal.
|
||||||
|
func isStringEqual(s1 string, s2 string) bool {
|
||||||
|
if runtime.GOOS == globalWindowsOSName {
|
||||||
|
return strings.EqualFold(s1, s2)
|
||||||
|
}
|
||||||
|
return s1 == s2
|
||||||
|
}
|
||||||
|
|
||||||
// Ignores all reserved bucket names or invalid bucket names.
|
// Ignores all reserved bucket names or invalid bucket names.
|
||||||
func isReservedOrInvalidBucket(bucketEntry string) bool {
|
func isReservedOrInvalidBucket(bucketEntry string) bool {
|
||||||
bucketEntry = strings.TrimSuffix(bucketEntry, slashSeparator)
|
bucketEntry = strings.TrimSuffix(bucketEntry, slashSeparator)
|
||||||
|
@ -64,7 +64,7 @@ func (xl xlObjects) CopyObject(srcBucket, srcObject, dstBucket, dstObject string
|
|||||||
length := xlMeta.Stat.Size
|
length := xlMeta.Stat.Size
|
||||||
|
|
||||||
// Check if this request is only metadata update.
|
// Check if this request is only metadata update.
|
||||||
cpMetadataOnly := strings.EqualFold(pathJoin(srcBucket, srcObject), pathJoin(dstBucket, dstObject))
|
cpMetadataOnly := isStringEqual(pathJoin(srcBucket, srcObject), pathJoin(dstBucket, dstObject))
|
||||||
if cpMetadataOnly {
|
if cpMetadataOnly {
|
||||||
xlMeta.Meta = metadata
|
xlMeta.Meta = metadata
|
||||||
partsMetadata := make([]xlMetaV1, len(xl.storageDisks))
|
partsMetadata := make([]xlMetaV1, len(xl.storageDisks))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user