forked from TrueCloudLab/frostfs-node
[#1418] blobstor: Do not use pointers as parameters
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
14366bbd89
commit
b0c7b7851a
3 changed files with 12 additions and 9 deletions
|
@ -24,7 +24,7 @@ func (p *GetPrm) SetAddress(addr oid.Address) {
|
|||
}
|
||||
|
||||
// Object returns binary representation of the requested object.
|
||||
func (p *GetRes) Object() []byte {
|
||||
func (p GetRes) Object() []byte {
|
||||
return p.obj
|
||||
}
|
||||
|
||||
|
|
|
@ -212,7 +212,7 @@ func (b *blobovniczas) get(prm GetSmallPrm) (res *GetSmallRes, err error) {
|
|||
if prm.blobovniczaID != nil {
|
||||
blz, err := b.openBlobovnicza(prm.blobovniczaID.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return res, err
|
||||
}
|
||||
|
||||
return b.getObject(blz, bPrm)
|
||||
|
@ -245,7 +245,7 @@ func (b *blobovniczas) get(prm GetSmallPrm) (res *GetSmallRes, err error) {
|
|||
// not found in any blobovnicza
|
||||
var errNotFound apistatus.ObjectNotFound
|
||||
|
||||
return nil, errNotFound
|
||||
return res, errNotFound
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -262,13 +262,14 @@ func (b *blobovniczas) delete(prm DeleteSmallPrm) (res *DeleteSmallRes, err erro
|
|||
if prm.blobovniczaID != nil {
|
||||
blz, err := b.openBlobovnicza(prm.blobovniczaID.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return res, err
|
||||
}
|
||||
|
||||
return b.deleteObject(blz, bPrm, prm)
|
||||
}
|
||||
|
||||
activeCache := make(map[string]struct{})
|
||||
objectFound := false
|
||||
|
||||
err = b.iterateSortedLeaves(&prm.addr, func(p string) (bool, error) {
|
||||
dirPath := filepath.Dir(p)
|
||||
|
@ -289,14 +290,14 @@ func (b *blobovniczas) delete(prm DeleteSmallPrm) (res *DeleteSmallRes, err erro
|
|||
activeCache[dirPath] = struct{}{}
|
||||
|
||||
if err == nil {
|
||||
res = new(DeleteSmallRes)
|
||||
objectFound = true
|
||||
}
|
||||
|
||||
// abort iterator if found, otherwise process all blobovniczas
|
||||
return err == nil, nil
|
||||
})
|
||||
|
||||
if err == nil && res == nil {
|
||||
if err == nil && !objectFound {
|
||||
// not found in any blobovnicza
|
||||
var errNotFound apistatus.ObjectNotFound
|
||||
|
||||
|
@ -321,6 +322,7 @@ func (b *blobovniczas) getRange(prm GetRangeSmallPrm) (res *GetRangeSmallRes, er
|
|||
}
|
||||
|
||||
activeCache := make(map[string]struct{})
|
||||
objectFound := false
|
||||
|
||||
err = b.iterateSortedLeaves(&prm.addr, func(p string) (bool, error) {
|
||||
dirPath := filepath.Dir(p)
|
||||
|
@ -343,11 +345,13 @@ func (b *blobovniczas) getRange(prm GetRangeSmallPrm) (res *GetRangeSmallRes, er
|
|||
|
||||
activeCache[dirPath] = struct{}{}
|
||||
|
||||
objectFound = err == nil
|
||||
|
||||
// abort iterator if found, otherwise process all blobovniczas
|
||||
return err == nil, nil
|
||||
})
|
||||
|
||||
if err == nil && res == nil {
|
||||
if err == nil && !objectFound {
|
||||
// not found in any blobovnicza
|
||||
var errNotFound apistatus.ObjectNotFound
|
||||
|
||||
|
@ -566,7 +570,7 @@ func (b *blobovniczas) deleteObject(blz *blobovnicza.Blobovnicza, prm blobovnicz
|
|||
zap.Stringer("blobovnicza ID", dp.blobovniczaID),
|
||||
)
|
||||
|
||||
return new(DeleteSmallRes), nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// reads object from blobovnicza and returns GetSmallRes.
|
||||
|
|
|
@ -55,7 +55,6 @@ func (s *Shard) Put(prm PutPrm) (*PutRes, error) {
|
|||
res *blobstor.PutRes
|
||||
)
|
||||
|
||||
// res == nil if there is no writeCache or writeCache.Put has been failed
|
||||
if res, err = s.blobStor.Put(putPrm); err != nil {
|
||||
return nil, fmt.Errorf("could not put object to BLOB storage: %w", err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue