Skip to content

Commit

Permalink
*: Return correct info about owner
Browse files Browse the repository at this point in the history
These changes fixes test_s3.py::test_versioning_obj_suspend_versions test.

Signed-off-by: Evgenii Baidakov <[email protected]>
  • Loading branch information
smallhive committed May 31, 2024
1 parent 6301a76 commit 54a811f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 40 deletions.
17 changes: 9 additions & 8 deletions api/data/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ type (
IsDir bool
IsDeleteMarker bool

Bucket string
Name string
Size int64
ContentType string
Created time.Time
HashSum string
Owner user.ID
Headers map[string]string
Bucket string
Name string
Size int64
ContentType string
Created time.Time
HashSum string
Owner user.ID
OwnerPublicKey keys.PublicKey
Headers map[string]string
}

// NotificationInfo store info to send s3 notification.
Expand Down
3 changes: 2 additions & 1 deletion api/handler/object_list.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package handler

import (
"encoding/hex"
"net/http"
"net/url"
"strconv"
Expand Down Expand Up @@ -277,7 +278,7 @@ func encodeListObjectVersionsToResponse(info *layer.ListObjectVersionsInfo, buck
Key: ver.ObjectInfo.Name,
LastModified: ver.ObjectInfo.Created.UTC().Format(time.RFC3339),
Owner: Owner{
ID: ver.ObjectInfo.Owner.String(),
ID: hex.EncodeToString(ver.ObjectInfo.OwnerPublicKey.Bytes()),
DisplayName: ver.ObjectInfo.Owner.String(),
},
Size: ver.ObjectInfo.Size,
Expand Down
32 changes: 17 additions & 15 deletions api/layer/multipart_upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,12 @@ func (n *layer) uploadPart(ctx context.Context, multipartInfo *data.MultipartInf
ID: id,
CID: bktInfo.CID,

Owner: bktInfo.Owner,
Bucket: bktInfo.Name,
Size: partInfo.Size,
Created: partInfo.Created,
HashSum: partInfo.ETag,
Owner: bktInfo.Owner,
OwnerPublicKey: bktInfo.OwnerPublicKey,
Bucket: bktInfo.Name,
Size: partInfo.Size,
Created: partInfo.Created,
HashSum: partInfo.ETag,
}

return objInfo, nil
Expand Down Expand Up @@ -723,16 +724,17 @@ func (n *layer) CompleteMultipartUpload(ctx context.Context, p *CompleteMultipar
n.cache.CleanListCacheEntriesContainingObject(p.Info.Key, p.Info.Bkt.CID)

objInfo := &data.ObjectInfo{
ID: headerObjectID,
CID: p.Info.Bkt.CID,
Owner: p.Info.Bkt.Owner,
Bucket: p.Info.Bkt.Name,
Name: p.Info.Key,
Size: multipartObjetSize,
Created: prm.CreationTime,
Headers: initMetadata,
ContentType: initMetadata[api.ContentType],
HashSum: newVersion.ETag,
ID: headerObjectID,
CID: p.Info.Bkt.CID,
Owner: p.Info.Bkt.Owner,
OwnerPublicKey: p.Info.Bkt.OwnerPublicKey,
Bucket: p.Info.Bkt.Name,
Name: p.Info.Key,
Size: multipartObjetSize,
Created: prm.CreationTime,
Headers: initMetadata,
ContentType: initMetadata[api.ContentType],
HashSum: newVersion.ETag,
}

extObjInfo := &data.ExtendedObjectInfo{
Expand Down
17 changes: 9 additions & 8 deletions api/layer/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,15 @@ func (n *layer) PutObject(ctx context.Context, p *PutObjectParams) (*data.Extend
ID: id,
CID: p.BktInfo.CID,

Owner: owner,
Bucket: p.BktInfo.Name,
Name: p.Object,
Size: p.Size,
Created: prm.CreationTime,
Headers: p.Header,
ContentType: p.Header[api.ContentType],
HashSum: newVersion.ETag,
Owner: owner,
OwnerPublicKey: p.BktInfo.OwnerPublicKey,
Bucket: p.BktInfo.Name,
Name: p.Object,
Size: p.Size,
Created: prm.CreationTime,
Headers: p.Header,
ContentType: p.Header[api.ContentType],
HashSum: newVersion.ETag,
}

extendedObjInfo := &data.ExtendedObjectInfo{
Expand Down
17 changes: 9 additions & 8 deletions api/layer/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,15 @@ func objectInfoFromMeta(bkt *data.BucketInfo, meta *object.Object) *data.ObjectI
CID: bkt.CID,
IsDir: false,

Bucket: bkt.Name,
Name: filepathFromObject(meta),
Created: creation,
ContentType: mimeType,
Headers: customHeaders,
Owner: *meta.OwnerID(),
Size: int64(meta.PayloadSize()),
HashSum: hex.EncodeToString(payloadChecksum.Value()),
Bucket: bkt.Name,
Name: filepathFromObject(meta),
Created: creation,
ContentType: mimeType,
Headers: customHeaders,
Owner: *meta.OwnerID(),
OwnerPublicKey: bkt.OwnerPublicKey,
Size: int64(meta.PayloadSize()),
HashSum: hex.EncodeToString(payloadChecksum.Value()),
}
}

Expand Down

0 comments on commit 54a811f

Please sign in to comment.