[#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 {
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(),
})
}

View file

@ -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
}
)

View file

@ -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)