[#577] Remove ObjectVersionInfo

Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
Angira Kekteeva 2022-08-02 01:48:24 +04:00 committed by Kira
parent 2d58b25ea0
commit eaf76afe50
3 changed files with 20 additions and 36 deletions

View file

@ -272,34 +272,34 @@ func encodeListObjectVersionsToResponse(info *layer.ListObjectVersionsInfo, buck
} }
for _, ver := range info.Version { for _, ver := range info.Version {
versionID := ver.Object.Version() versionID := ver.ObjectInfo.Version()
if ver.IsUnversioned { if ver.NodeVersion.IsUnversioned {
versionID = layer.UnversionedObjectVersionID versionID = layer.UnversionedObjectVersionID
} }
res.Version = append(res.Version, ObjectVersionResponse{ res.Version = append(res.Version, ObjectVersionResponse{
IsLatest: ver.IsLatest, IsLatest: ver.IsLatest,
Key: ver.Object.Name, Key: ver.ObjectInfo.Name,
LastModified: ver.Object.Created.UTC().Format(time.RFC3339), LastModified: ver.ObjectInfo.Created.UTC().Format(time.RFC3339),
Owner: Owner{ Owner: Owner{
ID: ver.Object.Owner.String(), ID: ver.ObjectInfo.Owner.String(),
DisplayName: ver.Object.Owner.String(), DisplayName: ver.ObjectInfo.Owner.String(),
}, },
Size: ver.Object.Size, Size: ver.ObjectInfo.Size,
VersionID: versionID, VersionID: versionID,
ETag: ver.Object.HashSum, ETag: ver.ObjectInfo.HashSum,
}) })
} }
// this loop is not starting till versioning is not implemented // this loop is not starting till versioning is not implemented
for _, del := range info.DeleteMarker { for _, del := range info.DeleteMarker {
res.DeleteMarker = append(res.DeleteMarker, DeleteMarkerEntry{ res.DeleteMarker = append(res.DeleteMarker, DeleteMarkerEntry{
IsLatest: del.IsLatest, IsLatest: del.IsLatest,
Key: del.Object.Name, Key: del.ObjectInfo.Name,
LastModified: del.Object.Created.UTC().Format(time.RFC3339), LastModified: del.ObjectInfo.Created.UTC().Format(time.RFC3339),
Owner: Owner{ Owner: Owner{
ID: del.Object.Owner.String(), ID: del.ObjectInfo.Owner.String(),
DisplayName: del.Object.Owner.String(), DisplayName: del.ObjectInfo.Owner.String(),
}, },
VersionID: del.Object.Version(), VersionID: del.ObjectInfo.Version(),
}) })
} }

View file

@ -35,13 +35,6 @@ type (
NextContinuationToken string 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 stores info and list of objects versions.
ListObjectVersionsInfo struct { ListObjectVersionsInfo struct {
CommonPrefixes []string CommonPrefixes []string
@ -49,8 +42,8 @@ type (
KeyMarker string KeyMarker string
NextKeyMarker string NextKeyMarker string
NextVersionIDMarker string NextVersionIDMarker string
Version []*ObjectVersionInfo Version []*data.ExtendedObjectInfo
DeleteMarker []*ObjectVersionInfo DeleteMarker []*data.ExtendedObjectInfo
VersionIDMarker string VersionIDMarker string
} }
) )

View file

@ -59,29 +59,20 @@ func (n *layer) ListObjectVersions(ctx context.Context, p *ListObjectVersionsPar
res.VersionIDMarker = allObjects[p.MaxKeys-1].ObjectInfo.Version() res.VersionIDMarker = allObjects[p.MaxKeys-1].ObjectInfo.Version()
} }
objects := make([]*ObjectVersionInfo, len(allObjects)) res.Version, res.DeleteMarker = triageVersions(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)
return res, nil return res, nil
} }
func triageVersions(objVersions []*ObjectVersionInfo) ([]*ObjectVersionInfo, []*ObjectVersionInfo) { func triageVersions(objVersions []*data.ExtendedObjectInfo) ([]*data.ExtendedObjectInfo, []*data.ExtendedObjectInfo) {
if len(objVersions) == 0 { if len(objVersions) == 0 {
return nil, nil return nil, nil
} }
var resVersion []*ObjectVersionInfo var resVersion []*data.ExtendedObjectInfo
var resDelMarkVersions []*ObjectVersionInfo var resDelMarkVersions []*data.ExtendedObjectInfo
for _, version := range objVersions { for _, version := range objVersions {
if version.Object.IsDeleteMarker { if version.NodeVersion.DeleteMarker != nil {
resDelMarkVersions = append(resDelMarkVersions, version) resDelMarkVersions = append(resDelMarkVersions, version)
} else { } else {
resVersion = append(resVersion, version) resVersion = append(resVersion, version)