[#176] shard: Finalize the implementation of Exists method

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-18 17:38:49 +03:00 committed by Alex Vanin
parent 4518357ad7
commit 796bba3793
2 changed files with 12 additions and 3 deletions

View file

@ -2,6 +2,7 @@ package shard
import (
"github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/pkg/errors"
)
// ExistsPrm groups the parameters of Exists operation.
@ -33,8 +34,16 @@ func (p *ExistsRes) Exists() bool {
// Returns any error encountered that does not allow to
// unambiguously determine the presence of an object.
func (s *Shard) Exists(prm *ExistsPrm) (*ExistsRes, error) {
// FIXME: implement me
exists, err := s.objectExists(prm.addr)
if err != nil {
return nil, errors.Wrap(err, "could not check object presence in metabase")
}
return &ExistsRes{
ex: false,
ex: exists,
}, nil
}
func (s *Shard) objectExists(addr *object.Address) (bool, error) {
return s.metaBase.Exists(addr)
}

View file

@ -29,7 +29,7 @@ func (p *PutPrm) WithObject(obj *object.Object) *PutPrm {
// did not allow to completely save the object.
func (s *Shard) Put(prm *PutPrm) (*PutRes, error) {
// check object existence
ex, err := s.metaBase.Exists(prm.obj.Address())
ex, err := s.objectExists(prm.obj.Address())
if err != nil {
return nil, errors.Wrap(err, "could not check object existence")
} else if ex {