2020-11-17 16:29:00 +00:00
|
|
|
package blobstor
|
|
|
|
|
|
|
|
import (
|
2021-05-18 08:12:51 +00:00
|
|
|
"errors"
|
|
|
|
|
2022-07-05 14:07:40 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common"
|
2022-03-17 08:03:58 +00:00
|
|
|
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
2020-11-17 16:29:00 +00:00
|
|
|
)
|
|
|
|
|
2022-07-06 12:39:35 +00:00
|
|
|
// Get reads the object from b.
|
|
|
|
// If the descriptor is present, only one sub-storage is tried,
|
|
|
|
// Otherwise, each sub-storage is tried in order.
|
|
|
|
func (b *BlobStor) Get(prm common.GetPrm) (common.GetRes, error) {
|
2022-07-06 14:09:50 +00:00
|
|
|
if prm.StorageID == nil {
|
2022-07-06 12:39:35 +00:00
|
|
|
// Nothing specified, try everything.
|
|
|
|
res, err := b.getBig(prm)
|
|
|
|
if err == nil || !errors.As(err, new(apistatus.ObjectNotFound)) {
|
|
|
|
return res, err
|
|
|
|
}
|
|
|
|
return b.getSmall(prm)
|
|
|
|
}
|
2022-07-06 14:09:50 +00:00
|
|
|
if len(prm.StorageID) == 0 {
|
2022-07-06 12:39:35 +00:00
|
|
|
return b.getBig(prm)
|
|
|
|
}
|
|
|
|
return b.getSmall(prm)
|
|
|
|
}
|
|
|
|
|
|
|
|
// getBig reads the object from shallow dir of BLOB storage by address.
|
2020-11-17 16:29:00 +00:00
|
|
|
//
|
|
|
|
// Returns any error encountered that
|
2020-11-24 13:29:55 +00:00
|
|
|
// did not allow to completely read the object.
|
2020-11-30 16:39:05 +00:00
|
|
|
//
|
2022-04-21 11:28:05 +00:00
|
|
|
// Returns an error of type apistatus.ObjectNotFound if the requested object is not
|
2020-11-30 16:39:05 +00:00
|
|
|
// presented in shallow dir.
|
2022-07-06 12:39:35 +00:00
|
|
|
func (b *BlobStor) getBig(prm common.GetPrm) (common.GetRes, error) {
|
2020-11-17 16:29:00 +00:00
|
|
|
// get compressed object data
|
2022-07-08 07:09:48 +00:00
|
|
|
return b.fsTree.Get(prm)
|
2020-11-17 16:29:00 +00:00
|
|
|
}
|
2022-07-05 13:47:39 +00:00
|
|
|
|
2022-07-06 12:39:35 +00:00
|
|
|
func (b *BlobStor) getSmall(prm common.GetPrm) (common.GetRes, error) {
|
2022-07-05 13:47:39 +00:00
|
|
|
return b.blobovniczas.Get(prm)
|
|
|
|
}
|