ls: show ETag in json formatted output (#2285)

This commit is contained in:
poornas
2017-10-13 18:23:13 -07:00
committed by Dee Koder
parent 785e14a725
commit 26c7c3e500
3 changed files with 11 additions and 0 deletions
+6
View File
@@ -879,6 +879,7 @@ func (c *s3Client) Stat(isIncomplete bool) (*clientContent, *probe.Error) {
objectMetadata.URL = *c.targetURL
objectMetadata.Time = objectStat.LastModified
objectMetadata.Size = objectStat.Size
objectMetadata.ETag = objectStat.ETag
objectMetadata.Type = os.FileMode(0664)
objectMetadata.Metadata = map[string][]string{}
return objectMetadata, nil
@@ -915,6 +916,7 @@ func (c *s3Client) Stat(isIncomplete bool) (*clientContent, *probe.Error) {
objectMetadata.URL = *c.targetURL
objectMetadata.Time = objectStat.LastModified
objectMetadata.Size = objectStat.Size
objectMetadata.ETag = objectStat.ETag
objectMetadata.Type = os.FileMode(0664)
metadata := objectStat.Metadata
@@ -1252,6 +1254,7 @@ func (c *s3Client) objectInfo2ClientContent(entry minio.ObjectInfo) clientConten
url.Path = c.joinPath(bucket, entry.Key)
content.URL = url
content.Size = entry.Size
content.ETag = entry.ETag
content.Time = entry.LastModified
if strings.HasSuffix(entry.Key, "/") && entry.Size == 0 && entry.LastModified.IsZero() {
@@ -1429,6 +1432,7 @@ func (c *s3Client) listInRoutine(contentCh chan *clientContent) {
default:
content.URL = url
content.Size = object.Size
content.ETag = object.ETag
content.Time = object.LastModified
content.Type = os.FileMode(0664)
}
@@ -1484,6 +1488,7 @@ func (c *s3Client) listRecursiveInRoutine(contentCh chan *clientContent) {
objectURL.Path = c.joinPath(bucket.Name, object.Key)
content.URL = objectURL
content.Size = object.Size
content.ETag = object.ETag
content.Time = object.LastModified
content.Type = os.FileMode(0664)
contentCh <- content
@@ -1508,6 +1513,7 @@ func (c *s3Client) listRecursiveInRoutine(contentCh chan *clientContent) {
url.Path = c.joinPath(b, object.Key)
content.URL = url
content.Size = object.Size
content.ETag = object.ETag
content.Time = object.LastModified
content.Type = os.FileMode(0664)
contentCh <- content
+1
View File
@@ -80,6 +80,7 @@ type clientContent struct {
Time time.Time
Size int64
Type os.FileMode
ETag string
Metadata map[string][]string
Err *probe.Error
}
+4
View File
@@ -41,6 +41,7 @@ type contentMessage struct {
Time time.Time `json:"lastModified"`
Size int64 `json:"size"`
Key string `json:"key"`
ETag string `json:"etag"`
}
// String colorized string message.
@@ -79,6 +80,9 @@ func parseContent(c *clientContent) contentMessage {
}()
content.Size = c.Size
md5sum := strings.TrimPrefix(c.ETag, "\"")
md5sum = strings.TrimSuffix(md5sum, "\"")
content.ETag = md5sum
// Convert OS Type to match console file printing style.
content.Key = func() string {
switch {