2020-09-25 13:04:55 +00:00
|
|
|
package rangesvc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
2020-11-19 08:28:58 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
|
2020-09-25 13:04:55 +00:00
|
|
|
"github.com/pkg/errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
type localRangeWriter struct {
|
|
|
|
addr *object.Address
|
|
|
|
|
|
|
|
rng *object.Range
|
|
|
|
|
2020-11-19 08:28:58 +00:00
|
|
|
storage *engine.StorageEngine
|
2020-09-25 13:04:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (l *localRangeWriter) WriteTo(w io.Writer) (int64, error) {
|
2020-11-19 08:28:58 +00:00
|
|
|
rngData, err := engine.GetRange(l.storage, l.addr, l.rng)
|
2020-09-25 13:04:55 +00:00
|
|
|
if err != nil {
|
|
|
|
return 0, errors.Wrapf(err, "(%T) could not get object from local storage", l)
|
|
|
|
}
|
|
|
|
|
2020-11-19 08:28:58 +00:00
|
|
|
n, err := w.Write(rngData)
|
2020-09-25 13:04:55 +00:00
|
|
|
|
|
|
|
return int64(n), err
|
|
|
|
}
|