Handle directories properly in cp and mirror (#2478)

Fixes #2477
This commit is contained in:
Harshavardhana
2018-06-29 16:56:02 -07:00
committed by kannappanr
parent 29f2dbca6b
commit 64ef3a4e14
2 changed files with 15 additions and 27 deletions
-10
View File
@@ -13,16 +13,6 @@ matrix:
- diff -au <(gofmt -d *.go) <(printf "")
- diff -au <(gofmt -d cmd) <(printf "")
- diff -au <(gofmt -d pkg) <(printf "")
- os: linux-ppc64le
env:
- ARCH=ppc64le
go: 1.10.1
script:
- make test
- make coverage
- diff -au <(gofmt -d *.go) <(printf "")
- diff -au <(gofmt -d cmd) <(printf "")
- diff -au <(gofmt -d pkg) <(printf "")
after_success:
- bash <(curl -s https://codecov.io/bash)
+15 -17
View File
@@ -989,7 +989,21 @@ func (c *s3Client) Stat(isIncomplete, isFetchMeta bool, sseKey string) (*clientC
if objectStat.Err != nil {
return nil, probe.NewError(objectStat.Err)
}
if objectStat.Key == object {
if strings.HasSuffix(objectStat.Key, string(c.targetURL.Separator)) {
objectMetadata.URL = *c.targetURL
objectMetadata.Type = os.ModeDir
if isFetchMeta {
stat, err := c.getObjectStat(bucket, object, opts)
if err != nil {
return nil, err
}
objectMetadata.ETag = stat.ETag
objectMetadata.Metadata = stat.Metadata
objectMetadata.EncryptionHeaders = stat.EncryptionHeaders
}
return objectMetadata, nil
} else if objectStat.Key == object {
objectMetadata.URL = *c.targetURL
objectMetadata.Time = objectStat.LastModified
objectMetadata.Size = objectStat.Size
@@ -1007,22 +1021,6 @@ func (c *s3Client) Stat(isIncomplete, isFetchMeta bool, sseKey string) (*clientC
}
return objectMetadata, nil
}
if strings.HasSuffix(objectStat.Key, string(c.targetURL.Separator)) {
objectMetadata.URL = *c.targetURL
objectMetadata.Type = os.ModeDir
if isFetchMeta {
stat, err := c.getObjectStat(bucket, object, opts)
if err != nil {
return nil, err
}
objectMetadata.ETag = stat.ETag
objectMetadata.Metadata = stat.Metadata
objectMetadata.EncryptionHeaders = stat.EncryptionHeaders
}
return objectMetadata, nil
}
}
return c.getObjectStat(bucket, object, opts)
}