diff --git a/api/handler/object_list.go b/api/handler/object_list.go index 947d8db3a..5c6a88d33 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 7c0e7e542..437d71b77 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 49503ab33..2a3e16371 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)