From dd16f568c3cc8c99e02b793ae2b257f3a8c90bca Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Fri, 25 Sep 2020 15:42:28 +0300 Subject: [PATCH] [#50] object/head: Add right child to Head operation result Head service receives right child of the processing object in some cases. Add right child to Head result in order to use it as needed. Signed-off-by: Leonard Lyubich --- pkg/services/object/head/res.go | 6 +++++- pkg/services/object/head/service.go | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/services/object/head/res.go b/pkg/services/object/head/res.go index b64144f5..cad3542b 100644 --- a/pkg/services/object/head/res.go +++ b/pkg/services/object/head/res.go @@ -5,9 +5,13 @@ import ( ) type Response struct { - hdr *object.Object + hdr, rightChild *object.Object } func (r *Response) Header() *object.Object { return r.hdr } + +func (r *Response) RightChild() *object.Object { + return r.rightChild +} diff --git a/pkg/services/object/head/service.go b/pkg/services/object/head/service.go index 6bcd41a7..45e5bcb4 100644 --- a/pkg/services/object/head/service.go +++ b/pkg/services/object/head/service.go @@ -77,15 +77,18 @@ func (s *Service) Head(ctx context.Context, prm *Prm) (*Response, error) { addr.SetContainerID(prm.addr.GetContainerID()) addr.SetObjectID(rightChildID) - rightChild, err := s.Head(ctx, new(Prm).WithAddress(addr)) + r, err = s.Head(ctx, new(Prm).WithAddress(addr)) if err != nil { return nil, errors.Wrapf(err, "(%T) could not get right child header", s) } + rightChild := r.Header() + // TODO: check if received parent has requested address return &Response{ - hdr: object.NewFromSDK(rightChild.Header().GetParent()), + hdr: object.NewFromSDK(rightChild.GetParent()), + rightChild: rightChild, }, nil }