[#577] Rename objectInfo.Version() to VersionID()

Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
Angira Kekteeva 2022-08-04 21:31:33 +04:00 committed by Kira
parent eaf76afe50
commit 3ac3f1cc9d
10 changed files with 34 additions and 34 deletions

View file

@ -82,7 +82,7 @@ type (
func NotificationInfoFromObject(objInfo *ObjectInfo) *NotificationInfo {
return &NotificationInfo{
Name: objInfo.Name,
Version: objInfo.Version(),
Version: objInfo.VersionID(),
Size: objInfo.Size,
HashSum: objInfo.HashSum,
}
@ -98,8 +98,8 @@ func (b *BucketInfo) NotificationConfigurationObjectName() string {
return bktNotificationConfigurationObject
}
// Version returns object version from ObjectInfo.
func (o *ObjectInfo) Version() string { return o.ID.EncodeToString() }
// VersionID returns object version from ObjectInfo.
func (o *ObjectInfo) VersionID() string { return o.ID.EncodeToString() }
// NiceName returns object name for cache.
func (o *ObjectInfo) NiceName() string { return o.Bucket + "/" + o.Name }

View file

@ -307,7 +307,7 @@ func (h *handler) GetObjectACLHandler(w http.ResponseWriter, r *http.Request) {
return
}
if err = api.EncodeToResponse(w, h.encodeObjectACL(bucketACL, reqInfo.BucketName, objInfo.ObjectInfo.Version())); err != nil {
if err = api.EncodeToResponse(w, h.encodeObjectACL(bucketACL, reqInfo.BucketName, objInfo.ObjectInfo.VersionID())); err != nil {
h.logAndSendError(w, "failed to encode response", reqInfo, err)
}
}

View file

@ -26,7 +26,7 @@ func TestDeleteBucket(t *testing.T) {
require.True(t, isDeleteMarker)
deleteBucket(t, tc, bktName, http.StatusConflict)
deleteObject(t, tc, bktName, objName, objInfo.Version())
deleteObject(t, tc, bktName, objName, objInfo.VersionID())
deleteBucket(t, tc, bktName, http.StatusConflict)
deleteObject(t, tc, bktName, objName, deleteMarkerVersion)
deleteBucket(t, tc, bktName, http.StatusNoContent)
@ -86,13 +86,13 @@ func TestDeleteDeletedObject(t *testing.T) {
bktName, objName := "bucket-versioned-for-removal", "object-to-delete"
_, objInfo := createVersionedBucketAndObject(t, tc, bktName, objName)
versionID, isDeleteMarker := deleteObject(t, tc, bktName, objName, objInfo.Version())
versionID, isDeleteMarker := deleteObject(t, tc, bktName, objName, objInfo.VersionID())
require.False(t, isDeleteMarker)
require.Equal(t, objInfo.Version(), versionID)
require.Equal(t, objInfo.VersionID(), versionID)
versionID2, isDeleteMarker := deleteObject(t, tc, bktName, objName, versionID)
require.False(t, isDeleteMarker)
require.Equal(t, objInfo.Version(), versionID2)
require.Equal(t, objInfo.VersionID(), versionID2)
})
}
@ -106,9 +106,9 @@ func TestDeleteObjectVersioned(t *testing.T) {
deleteObject(t, tc, bktName, objName, emptyVersion)
checkNotFound(t, tc, bktName, objName, emptyVersion)
checkFound(t, tc, bktName, objName, objInfo.Version())
deleteObject(t, tc, bktName, objName, objInfo.Version())
checkNotFound(t, tc, bktName, objName, objInfo.Version())
checkFound(t, tc, bktName, objName, objInfo.VersionID())
deleteObject(t, tc, bktName, objName, objInfo.VersionID())
checkNotFound(t, tc, bktName, objName, objInfo.VersionID())
require.False(t, existInMockedNeoFS(tc, bktInfo, objInfo), "object exists but shouldn't")
}
@ -141,7 +141,7 @@ func TestRemoveDeleteMarker(t *testing.T) {
require.True(t, isDeleteMarker)
checkNotFound(t, tc, bktName, objName, emptyVersion)
checkFound(t, tc, bktName, objName, objInfo.Version())
checkFound(t, tc, bktName, objName, objInfo.VersionID())
deleteObject(t, tc, bktName, objName, deleteMarkerVersion)
checkFound(t, tc, bktName, objName, emptyVersion)
@ -160,7 +160,7 @@ func TestDeleteObjectCombined(t *testing.T) {
deleteObject(t, tc, bktName, objName, emptyVersion)
checkNotFound(t, tc, bktName, objName, emptyVersion)
checkFound(t, tc, bktName, objName, objInfo.Version())
checkFound(t, tc, bktName, objName, objInfo.VersionID())
require.True(t, existInMockedNeoFS(tc, bktInfo, objInfo), "object doesn't exist but should")
}
@ -180,7 +180,7 @@ func TestDeleteObjectSuspended(t *testing.T) {
putBucketVersioning(t, tc, bktName, false)
deleteObject(t, tc, bktName, objName, emptyVersion)
checkNotFound(t, tc, bktName, objName, objInfo.Version())
checkNotFound(t, tc, bktName, objName, objInfo.VersionID())
require.False(t, existInMockedNeoFS(tc, bktInfo, objInfo), "object exists but shouldn't")
}
@ -213,9 +213,9 @@ func TestDeleteObjectFromListCache(t *testing.T) {
versions := listObjectsV1(t, tc, bktName)
require.Len(t, versions.Contents, 1)
checkFound(t, tc, bktName, objName, objInfo.Version())
deleteObject(t, tc, bktName, objName, objInfo.Version())
checkNotFound(t, tc, bktName, objName, objInfo.Version())
checkFound(t, tc, bktName, objName, objInfo.VersionID())
deleteObject(t, tc, bktName, objName, objInfo.VersionID())
checkNotFound(t, tc, bktName, objName, objInfo.VersionID())
// check cache is clean after object removal
versions = listObjectsV1(t, tc, bktName)

View file

@ -141,7 +141,7 @@ func (h *handler) GetObjectHandler(w http.ResponseWriter, r *http.Request) {
t := &layer.ObjectVersion{
BktInfo: bktInfo,
ObjectName: info.Name,
VersionID: info.Version(),
VersionID: info.VersionID(),
}
tagSet, lockInfo, err := h.obj.GetObjectTaggingAndLock(r.Context(), t, extendedInfo.NodeVersion)

View file

@ -61,7 +61,7 @@ func (h *handler) HeadObjectHandler(w http.ResponseWriter, r *http.Request) {
t := &layer.ObjectVersion{
BktInfo: bktInfo,
ObjectName: info.Name,
VersionID: info.Version(),
VersionID: info.VersionID(),
}
tagSet, lockInfo, err := h.obj.GetObjectTaggingAndLock(r.Context(), t, extendedInfo.NodeVersion)

View file

@ -363,7 +363,7 @@ func (h *handler) CompleteMultipartUploadHandler(w http.ResponseWriter, r *http.
t := &layer.ObjectVersion{
BktInfo: bktInfo,
ObjectName: objInfo.Name,
VersionID: objInfo.Version(),
VersionID: objInfo.VersionID(),
}
if _, err = h.obj.PutObjectTagging(r.Context(), t, uploadData.TagSet); err != nil {
h.logAndSendError(w, "could not put tagging file of completed multipart upload", reqInfo, err, additional...)
@ -420,7 +420,7 @@ func (h *handler) CompleteMultipartUploadHandler(w http.ResponseWriter, r *http.
}
if bktSettings.VersioningEnabled() {
w.Header().Set(api.AmzVersionID, objInfo.Version())
w.Header().Set(api.AmzVersionID, objInfo.VersionID())
}
if err = api.EncodeToResponse(w, response); err != nil {

View file

@ -255,7 +255,7 @@ func (h *handler) PutObjectHandler(w http.ResponseWriter, r *http.Request) {
t := &layer.ObjectVersion{
BktInfo: bktInfo,
ObjectName: info.Name,
VersionID: info.Version(),
VersionID: info.VersionID(),
}
if tagSet != nil {
if _, err = h.obj.PutObjectTagging(r.Context(), t, tagSet); err != nil {
@ -278,7 +278,7 @@ func (h *handler) PutObjectHandler(w http.ResponseWriter, r *http.Request) {
}
if settings.VersioningEnabled() {
w.Header().Set(api.AmzVersionID, info.Version())
w.Header().Set(api.AmzVersionID, info.VersionID())
}
w.Header().Set(api.ETag, info.HashSum)
@ -382,7 +382,7 @@ func (h *handler) PostObject(w http.ResponseWriter, r *http.Request) {
t := &layer.ObjectVersion{
BktInfo: bktInfo,
ObjectName: info.Name,
VersionID: info.Version(),
VersionID: info.VersionID(),
}
if tagSet != nil {
@ -408,7 +408,7 @@ func (h *handler) PostObject(w http.ResponseWriter, r *http.Request) {
if settings, err := h.obj.GetBucketSettings(r.Context(), bktInfo); err != nil {
h.log.Warn("couldn't get bucket versioning", zap.String("bucket name", reqInfo.BucketName), zap.Error(err))
} else if settings.VersioningEnabled() {
w.Header().Set(api.AmzVersionID, info.Version())
w.Header().Set(api.AmzVersionID, info.VersionID())
}
if redirectURL := auth.MultipartFormValue(r, "success_action_redirect"); redirectURL != "" {
@ -508,7 +508,7 @@ func (h *handler) getNewEAclTable(r *http.Request, bktInfo *data.BucketInfo, obj
resInfo := &resourceInfo{
Bucket: objInfo.Bucket,
Object: objInfo.Name,
Version: objInfo.Version(),
Version: objInfo.VersionID(),
}
bktPolicy, err := aclToPolicy(objectACL, resInfo)

View file

@ -21,7 +21,7 @@ func TestObjectLockAttributes(t *testing.T) {
p := &ObjectVersion{
BktInfo: tc.bktInfo,
ObjectName: obj.Name,
VersionID: obj.Version(),
VersionID: obj.VersionID(),
}
lock := &data.ObjectLock{

View file

@ -41,7 +41,7 @@ func (n *layer) ListObjectVersions(ctx context.Context, p *ListObjectVersionsPar
}
for i, obj := range allObjects {
if obj.ObjectInfo.Name >= p.KeyMarker && obj.ObjectInfo.Version() >= p.VersionIDMarker {
if obj.ObjectInfo.Name >= p.KeyMarker && obj.ObjectInfo.VersionID() >= p.VersionIDMarker {
allObjects = allObjects[i:]
break
}
@ -52,11 +52,11 @@ func (n *layer) ListObjectVersions(ctx context.Context, p *ListObjectVersionsPar
if len(allObjects) > p.MaxKeys {
res.IsTruncated = true
res.NextKeyMarker = allObjects[p.MaxKeys].ObjectInfo.Name
res.NextVersionIDMarker = allObjects[p.MaxKeys].ObjectInfo.Version()
res.NextVersionIDMarker = allObjects[p.MaxKeys].ObjectInfo.VersionID()
allObjects = allObjects[:p.MaxKeys]
res.KeyMarker = allObjects[p.MaxKeys-1].ObjectInfo.Name
res.VersionIDMarker = allObjects[p.MaxKeys-1].ObjectInfo.Version()
res.VersionIDMarker = allObjects[p.MaxKeys-1].ObjectInfo.VersionID()
}
res.Version, res.DeleteMarker = triageVersions(allObjects)

View file

@ -251,7 +251,7 @@ func TestGetUnversioned(t *testing.T) {
resInfo, buffer := tc.getObject(tc.obj, UnversionedObjectVersionID, false)
require.Equal(t, objContent, buffer)
require.Equal(t, objInfo.Version(), resInfo.Version())
require.Equal(t, objInfo.VersionID(), resInfo.VersionID())
}
func TestVersioningDeleteSpecificObjectVersion(t *testing.T) {
@ -268,8 +268,8 @@ func TestVersioningDeleteSpecificObjectVersion(t *testing.T) {
objV3Content := []byte("content obj1 v3")
objV3Info := tc.putObject(objV3Content)
tc.deleteObject(tc.obj, objV2Info.Version(), settings)
tc.getObject(tc.obj, objV2Info.Version(), true)
tc.deleteObject(tc.obj, objV2Info.VersionID(), settings)
tc.getObject(tc.obj, objV2Info.VersionID(), true)
_, buffer3 := tc.getObject(tc.obj, "", false)
require.Equal(t, objV3Content, buffer3)
@ -286,7 +286,7 @@ func TestVersioningDeleteSpecificObjectVersion(t *testing.T) {
resInfo, buffer := tc.getObject(tc.obj, "", false)
require.Equal(t, objV3Content, buffer)
require.Equal(t, objV3Info.Version(), resInfo.Version())
require.Equal(t, objV3Info.VersionID(), resInfo.VersionID())
}
func TestNoVersioningDeleteObject(t *testing.T) {