2020-11-24 14:15:58 +00:00
|
|
|
package blobstor
|
|
|
|
|
|
|
|
import (
|
2022-03-04 12:57:43 +00:00
|
|
|
"errors"
|
2021-05-18 08:12:51 +00:00
|
|
|
|
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-24 14:15:58 +00:00
|
|
|
)
|
|
|
|
|
2022-07-06 12:39:35 +00:00
|
|
|
// GetRange reads object payload data from b.
|
|
|
|
// If the descriptor is present, only one sub-storage is tried,
|
|
|
|
// Otherwise, each sub-storage is tried in order.
|
|
|
|
func (b *BlobStor) GetRange(prm common.GetRangePrm) (common.GetRangeRes, error) {
|
2022-07-06 14:09:50 +00:00
|
|
|
if prm.StorageID == nil {
|
2022-07-08 11:33:49 +00:00
|
|
|
for i := range b.storage {
|
|
|
|
res, err := b.storage[i].Storage.GetRange(prm)
|
|
|
|
if err == nil || !errors.As(err, new(apistatus.ObjectNotFound)) {
|
|
|
|
return res, err
|
|
|
|
}
|
2022-07-06 12:39:35 +00:00
|
|
|
}
|
|
|
|
|
2022-07-08 11:33:49 +00:00
|
|
|
var errNotFound apistatus.ObjectNotFound
|
|
|
|
return common.GetRangeRes{}, errNotFound
|
2020-11-24 14:15:58 +00:00
|
|
|
}
|
2022-07-08 11:33:49 +00:00
|
|
|
if len(prm.StorageID) == 0 {
|
2022-07-11 12:34:17 +00:00
|
|
|
return b.storage[len(b.storage)-1].Storage.GetRange(prm)
|
2020-11-24 14:15:58 +00:00
|
|
|
}
|
2022-07-08 11:33:49 +00:00
|
|
|
return b.storage[0].Storage.GetRange(prm)
|
2022-07-05 13:47:39 +00:00
|
|
|
}
|