From eaf76afe505b8bd452ec77fdf13880513bf39d69 Mon Sep 17 00:00:00 2001 From: Angira Kekteeva Date: Tue, 2 Aug 2022 01:48:24 +0400 Subject: [PATCH] [#577] Remove ObjectVersionInfo Signed-off-by: Angira Kekteeva --- api/handler/object_list.go | 26 +++++++++++++------------- api/layer/util.go | 11 ++--------- api/layer/versioning.go | 19 +++++-------------- 3 files changed, 20 insertions(+), 36 deletions(-) diff --git a/api/handler/object_list.go b/api/handler/object_list.go index 947d8db3..5c6a88d3 100644 --- a/api/handler/object_list.go +++ b/api/handler/object_list.go @@ -272,34 +272,34 @@ func encodeListObjectVersionsToResponse(info *layer.ListObjectVersionsInfo, buck } for _, ver := range info.Version { - versionID := ver.Object.Version() - if ver.IsUnversioned { + versionID := ver.ObjectInfo.Version() + if ver.NodeVersion.IsUnversioned { versionID = layer.UnversionedObjectVersionID } res.Version = append(res.Version, ObjectVersionResponse{ IsLatest: ver.IsLatest, - Key: ver.Object.Name, - LastModified: ver.Object.Created.UTC().Format(time.RFC3339), + Key: ver.ObjectInfo.Name, + LastModified: ver.ObjectInfo.Created.UTC().Format(time.RFC3339), Owner: Owner{ - ID: ver.Object.Owner.String(), - DisplayName: ver.Object.Owner.String(), + ID: ver.ObjectInfo.Owner.String(), + DisplayName: ver.ObjectInfo.Owner.String(), }, - Size: ver.Object.Size, + Size: ver.ObjectInfo.Size, VersionID: versionID, - ETag: ver.Object.HashSum, + ETag: ver.ObjectInfo.HashSum, }) } // this loop is not starting till versioning is not implemented for _, del := range info.DeleteMarker { res.DeleteMarker = append(res.DeleteMarker, DeleteMarkerEntry{ IsLatest: del.IsLatest, - Key: del.Object.Name, - LastModified: del.Object.Created.UTC().Format(time.RFC3339), + Key: del.ObjectInfo.Name, + LastModified: del.ObjectInfo.Created.UTC().Format(time.RFC3339), Owner: Owner{ - ID: del.Object.Owner.String(), - DisplayName: del.Object.Owner.String(), + ID: del.ObjectInfo.Owner.String(), + DisplayName: del.ObjectInfo.Owner.String(), }, - VersionID: del.Object.Version(), + VersionID: del.ObjectInfo.Version(), }) } diff --git a/api/layer/util.go b/api/layer/util.go index 7c0e7e54..437d71b7 100644 --- a/api/layer/util.go +++ b/api/layer/util.go @@ -35,13 +35,6 @@ type ( NextContinuationToken string } - // ObjectVersionInfo stores info about objects versions. - ObjectVersionInfo struct { - Object *data.ObjectInfo - IsLatest bool - IsUnversioned bool - } - // ListObjectVersionsInfo stores info and list of objects versions. ListObjectVersionsInfo struct { CommonPrefixes []string @@ -49,8 +42,8 @@ type ( KeyMarker string NextKeyMarker string NextVersionIDMarker string - Version []*ObjectVersionInfo - DeleteMarker []*ObjectVersionInfo + Version []*data.ExtendedObjectInfo + DeleteMarker []*data.ExtendedObjectInfo VersionIDMarker string } ) diff --git a/api/layer/versioning.go b/api/layer/versioning.go index 49503ab3..2a3e1637 100644 --- a/api/layer/versioning.go +++ b/api/layer/versioning.go @@ -59,29 +59,20 @@ func (n *layer) ListObjectVersions(ctx context.Context, p *ListObjectVersionsPar res.VersionIDMarker = allObjects[p.MaxKeys-1].ObjectInfo.Version() } - objects := make([]*ObjectVersionInfo, len(allObjects)) - for i, obj := range allObjects { - objects[i] = &ObjectVersionInfo{ - Object: obj.ObjectInfo, - IsUnversioned: obj.NodeVersion.IsUnversioned, - IsLatest: obj.IsLatest, - } - } - - res.Version, res.DeleteMarker = triageVersions(objects) + res.Version, res.DeleteMarker = triageVersions(allObjects) return res, nil } -func triageVersions(objVersions []*ObjectVersionInfo) ([]*ObjectVersionInfo, []*ObjectVersionInfo) { +func triageVersions(objVersions []*data.ExtendedObjectInfo) ([]*data.ExtendedObjectInfo, []*data.ExtendedObjectInfo) { if len(objVersions) == 0 { return nil, nil } - var resVersion []*ObjectVersionInfo - var resDelMarkVersions []*ObjectVersionInfo + var resVersion []*data.ExtendedObjectInfo + var resDelMarkVersions []*data.ExtendedObjectInfo for _, version := range objVersions { - if version.Object.IsDeleteMarker { + if version.NodeVersion.DeleteMarker != nil { resDelMarkVersions = append(resDelMarkVersions, version) } else { resVersion = append(resVersion, version)