2020-09-26 07:54:03 +00:00
|
|
|
package getsvc
|
|
|
|
|
|
|
|
import (
|
2021-04-29 12:18:29 +00:00
|
|
|
"context"
|
2020-12-08 16:18:24 +00:00
|
|
|
"crypto/sha256"
|
|
|
|
"hash"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
objectV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/object"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/status"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/client"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network"
|
|
|
|
objectSvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object"
|
|
|
|
getsvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/get"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/util"
|
2023-08-04 11:14:07 +00:00
|
|
|
clientSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
2023-03-07 13:38:26 +00:00
|
|
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
2023-07-06 12:36:41 +00:00
|
|
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
2023-03-07 13:38:26 +00:00
|
|
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
|
|
|
versionSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/version"
|
|
|
|
"git.frostfs.info/TrueCloudLab/tzhash/tz"
|
2020-09-26 07:54:03 +00:00
|
|
|
)
|
|
|
|
|
2020-12-02 23:45:25 +00:00
|
|
|
func (s *Service) toPrm(req *objectV2.GetRequest, stream objectSvc.GetObjectStream) (*getsvc.Prm, error) {
|
2022-05-31 17:00:41 +00:00
|
|
|
body := req.GetBody()
|
|
|
|
|
|
|
|
addrV2 := body.GetAddress()
|
|
|
|
if addrV2 == nil {
|
2023-04-24 10:11:44 +00:00
|
|
|
return nil, errMissingObjAddress
|
2022-05-31 17:00:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var addr oid.Address
|
|
|
|
|
|
|
|
err := addr.ReadFromV2(*addrV2)
|
|
|
|
if err != nil {
|
2023-04-24 10:11:44 +00:00
|
|
|
return nil, errInvalidObjAddress(err)
|
2022-05-31 17:00:41 +00:00
|
|
|
}
|
|
|
|
|
2021-01-12 14:55:02 +00:00
|
|
|
commonPrm, err := util.CommonPrmFromV2(req)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2022-07-15 06:55:53 +00:00
|
|
|
streamWrapper := &streamObjectWriter{stream}
|
|
|
|
|
2020-12-02 23:45:25 +00:00
|
|
|
p := new(getsvc.Prm)
|
2021-10-26 13:02:46 +00:00
|
|
|
p.SetCommonParameters(commonPrm)
|
2020-12-02 23:45:25 +00:00
|
|
|
|
2022-05-31 17:00:41 +00:00
|
|
|
p.WithAddress(addr)
|
2020-12-07 17:49:47 +00:00
|
|
|
p.WithRawFlag(body.GetRaw())
|
2022-07-15 06:55:53 +00:00
|
|
|
p.SetObjectWriter(streamWrapper)
|
2020-12-02 23:45:25 +00:00
|
|
|
|
2021-04-29 12:18:29 +00:00
|
|
|
if !commonPrm.LocalOnly() {
|
2023-04-04 10:20:57 +00:00
|
|
|
key, err := s.keyStorage.GetKey(nil)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-03-31 14:38:38 +00:00
|
|
|
forwarder := &getRequestForwarder{
|
2023-05-30 07:14:37 +00:00
|
|
|
GlobalProgress: 0,
|
|
|
|
Key: key,
|
|
|
|
Request: req,
|
|
|
|
Stream: streamWrapper,
|
2023-03-31 14:38:38 +00:00
|
|
|
}
|
2022-11-30 17:36:34 +00:00
|
|
|
|
2023-04-03 08:17:59 +00:00
|
|
|
p.SetRequestForwarder(groupAddressRequestForwarder(forwarder.forwardRequestToNode))
|
2021-04-29 12:18:29 +00:00
|
|
|
}
|
|
|
|
|
2020-12-02 23:45:25 +00:00
|
|
|
return p, nil
|
2020-09-26 07:54:03 +00:00
|
|
|
}
|
|
|
|
|
2020-12-07 17:49:47 +00:00
|
|
|
func (s *Service) toRangePrm(req *objectV2.GetRangeRequest, stream objectSvc.GetObjectRangeStream) (*getsvc.RangePrm, error) {
|
2022-05-31 17:00:41 +00:00
|
|
|
body := req.GetBody()
|
|
|
|
|
|
|
|
addrV2 := body.GetAddress()
|
|
|
|
if addrV2 == nil {
|
2023-04-24 10:11:44 +00:00
|
|
|
return nil, errMissingObjAddress
|
2022-05-31 17:00:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var addr oid.Address
|
|
|
|
|
|
|
|
err := addr.ReadFromV2(*addrV2)
|
|
|
|
if err != nil {
|
2023-04-24 10:11:44 +00:00
|
|
|
return nil, errInvalidObjAddress(err)
|
2022-05-31 17:00:41 +00:00
|
|
|
}
|
|
|
|
|
2021-01-12 14:55:02 +00:00
|
|
|
commonPrm, err := util.CommonPrmFromV2(req)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-12-07 17:49:47 +00:00
|
|
|
p := new(getsvc.RangePrm)
|
2021-10-26 13:02:46 +00:00
|
|
|
p.SetCommonParameters(commonPrm)
|
2020-12-07 17:49:47 +00:00
|
|
|
|
2022-07-15 06:55:53 +00:00
|
|
|
streamWrapper := &streamObjectRangeWriter{stream}
|
|
|
|
|
2022-05-31 17:00:41 +00:00
|
|
|
p.WithAddress(addr)
|
2020-12-07 17:49:47 +00:00
|
|
|
p.WithRawFlag(body.GetRaw())
|
2022-07-15 06:55:53 +00:00
|
|
|
p.SetChunkWriter(streamWrapper)
|
2023-07-06 12:36:41 +00:00
|
|
|
p.SetRange(objectSDK.NewRangeFromV2(body.GetRange()))
|
2020-12-07 17:49:47 +00:00
|
|
|
|
2022-11-24 14:28:50 +00:00
|
|
|
err = p.Validate()
|
|
|
|
if err != nil {
|
2023-04-24 10:11:44 +00:00
|
|
|
return nil, errRequestParamsValidation(err)
|
2022-11-24 14:28:50 +00:00
|
|
|
}
|
|
|
|
|
2021-04-29 12:18:29 +00:00
|
|
|
if !commonPrm.LocalOnly() {
|
2023-04-04 10:20:57 +00:00
|
|
|
key, err := s.keyStorage.GetKey(nil)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-03-31 14:41:42 +00:00
|
|
|
forwarder := &getRangeRequestForwarder{
|
|
|
|
GlobalProgress: 0,
|
2023-04-04 10:20:57 +00:00
|
|
|
Key: key,
|
2023-03-31 14:41:42 +00:00
|
|
|
Request: req,
|
|
|
|
Stream: streamWrapper,
|
2021-10-26 12:07:28 +00:00
|
|
|
}
|
|
|
|
|
2023-04-03 08:17:59 +00:00
|
|
|
p.SetRequestForwarder(groupAddressRequestForwarder(forwarder.forwardRequestToNode))
|
2021-04-29 12:18:29 +00:00
|
|
|
}
|
|
|
|
|
2020-12-07 17:49:47 +00:00
|
|
|
return p, nil
|
|
|
|
}
|
|
|
|
|
2020-12-08 16:18:24 +00:00
|
|
|
func (s *Service) toHashRangePrm(req *objectV2.GetRangeHashRequest) (*getsvc.RangeHashPrm, error) {
|
2022-05-31 17:00:41 +00:00
|
|
|
body := req.GetBody()
|
|
|
|
|
|
|
|
addrV2 := body.GetAddress()
|
|
|
|
if addrV2 == nil {
|
2023-04-24 10:11:44 +00:00
|
|
|
return nil, errMissingObjAddress
|
2022-05-31 17:00:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var addr oid.Address
|
|
|
|
|
|
|
|
err := addr.ReadFromV2(*addrV2)
|
|
|
|
if err != nil {
|
2023-04-24 10:11:44 +00:00
|
|
|
return nil, errInvalidObjAddress(err)
|
2022-05-31 17:00:41 +00:00
|
|
|
}
|
|
|
|
|
2021-01-12 14:55:02 +00:00
|
|
|
commonPrm, err := util.CommonPrmFromV2(req)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-12-08 16:18:24 +00:00
|
|
|
p := new(getsvc.RangeHashPrm)
|
2021-10-26 13:02:46 +00:00
|
|
|
p.SetCommonParameters(commonPrm)
|
2020-12-08 16:18:24 +00:00
|
|
|
|
2022-05-31 17:00:41 +00:00
|
|
|
p.WithAddress(addr)
|
2020-12-08 16:18:24 +00:00
|
|
|
|
2022-12-21 16:32:08 +00:00
|
|
|
if tok := commonPrm.SessionToken(); tok != nil {
|
|
|
|
signerKey, err := s.keyStorage.GetKey(&util.SessionInfo{
|
|
|
|
ID: tok.ID(),
|
|
|
|
Owner: tok.Issuer(),
|
|
|
|
})
|
2023-08-04 11:14:07 +00:00
|
|
|
if err != nil && clientSDK.IsErrSessionNotFound(err) {
|
2022-12-21 16:32:08 +00:00
|
|
|
commonPrm.ForgetTokens()
|
|
|
|
signerKey, err = s.keyStorage.GetKey(nil)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err != nil {
|
2023-04-24 10:11:44 +00:00
|
|
|
return nil, errFetchingSessionKey(err)
|
2022-12-21 16:32:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
p.WithCachedSignerKey(signerKey)
|
|
|
|
}
|
|
|
|
|
2020-12-08 16:18:24 +00:00
|
|
|
rngsV2 := body.GetRanges()
|
2023-07-06 12:36:41 +00:00
|
|
|
rngs := make([]objectSDK.Range, len(rngsV2))
|
2020-12-08 16:18:24 +00:00
|
|
|
|
|
|
|
for i := range rngsV2 {
|
2023-07-06 12:36:41 +00:00
|
|
|
rngs[i] = *objectSDK.NewRangeFromV2(&rngsV2[i])
|
2020-12-08 16:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
p.SetRangeList(rngs)
|
2021-01-11 13:50:04 +00:00
|
|
|
p.SetSalt(body.GetSalt())
|
2020-12-08 16:18:24 +00:00
|
|
|
|
|
|
|
switch t := body.GetType(); t {
|
|
|
|
default:
|
2023-04-24 10:11:44 +00:00
|
|
|
return nil, errUnknownChechsumType(t)
|
2020-12-08 16:18:24 +00:00
|
|
|
case refs.SHA256:
|
|
|
|
p.SetHashGenerator(func() hash.Hash {
|
|
|
|
return sha256.New()
|
|
|
|
})
|
|
|
|
case refs.TillichZemor:
|
|
|
|
p.SetHashGenerator(func() hash.Hash {
|
|
|
|
return tz.New()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return p, nil
|
|
|
|
}
|
|
|
|
|
2020-12-09 10:32:33 +00:00
|
|
|
type headResponseWriter struct {
|
|
|
|
mainOnly bool
|
|
|
|
|
|
|
|
body *objectV2.HeadResponseBody
|
|
|
|
}
|
|
|
|
|
2023-07-06 12:36:41 +00:00
|
|
|
func (w *headResponseWriter) WriteHeader(_ context.Context, hdr *objectSDK.Object) error {
|
2020-12-09 10:32:33 +00:00
|
|
|
if w.mainOnly {
|
|
|
|
w.body.SetHeaderPart(toShortObjectHeader(hdr))
|
|
|
|
} else {
|
|
|
|
w.body.SetHeaderPart(toFullObjectHeader(hdr))
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-03-13 11:37:35 +00:00
|
|
|
func (s *Service) toHeadPrm(req *objectV2.HeadRequest, resp *objectV2.HeadResponse) (*getsvc.HeadPrm, error) {
|
2022-05-31 17:00:41 +00:00
|
|
|
body := req.GetBody()
|
|
|
|
|
|
|
|
addrV2 := body.GetAddress()
|
|
|
|
if addrV2 == nil {
|
2023-04-24 10:11:44 +00:00
|
|
|
return nil, errMissingObjAddress
|
2022-05-31 17:00:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var objAddr oid.Address
|
|
|
|
|
|
|
|
err := objAddr.ReadFromV2(*addrV2)
|
|
|
|
if err != nil {
|
2023-04-24 10:11:44 +00:00
|
|
|
return nil, errInvalidObjAddress(err)
|
2022-05-31 17:00:41 +00:00
|
|
|
}
|
|
|
|
|
2021-01-12 14:55:02 +00:00
|
|
|
commonPrm, err := util.CommonPrmFromV2(req)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-12-09 10:32:33 +00:00
|
|
|
p := new(getsvc.HeadPrm)
|
2021-10-26 13:02:46 +00:00
|
|
|
p.SetCommonParameters(commonPrm)
|
2020-12-09 10:32:33 +00:00
|
|
|
|
2021-11-01 08:35:33 +00:00
|
|
|
p.WithAddress(objAddr)
|
2020-12-09 10:32:33 +00:00
|
|
|
p.WithRawFlag(body.GetRaw())
|
|
|
|
p.SetHeaderWriter(&headResponseWriter{
|
|
|
|
mainOnly: body.GetMainOnly(),
|
|
|
|
body: resp.GetBody(),
|
|
|
|
})
|
|
|
|
|
2023-03-21 14:53:09 +00:00
|
|
|
if commonPrm.LocalOnly() {
|
|
|
|
return p, nil
|
|
|
|
}
|
2021-04-29 12:18:29 +00:00
|
|
|
|
2023-04-04 10:20:57 +00:00
|
|
|
key, err := s.keyStorage.GetKey(nil)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-03-31 13:30:46 +00:00
|
|
|
forwarder := &headRequestForwarder{
|
|
|
|
Request: req,
|
|
|
|
ObjectAddr: objAddr,
|
2023-04-04 10:20:57 +00:00
|
|
|
Key: key,
|
2023-03-31 13:30:46 +00:00
|
|
|
}
|
2021-04-29 12:18:29 +00:00
|
|
|
|
2023-04-03 08:17:59 +00:00
|
|
|
p.SetRequestForwarder(groupAddressRequestForwarder(forwarder.forwardRequestToNode))
|
2021-04-29 12:18:29 +00:00
|
|
|
|
2020-12-09 10:32:33 +00:00
|
|
|
return p, nil
|
|
|
|
}
|
|
|
|
|
2023-07-06 12:36:41 +00:00
|
|
|
func splitInfoResponse(info *objectSDK.SplitInfo) *objectV2.GetResponse {
|
2020-12-02 23:45:25 +00:00
|
|
|
resp := new(objectV2.GetResponse)
|
|
|
|
|
|
|
|
body := new(objectV2.GetResponseBody)
|
|
|
|
resp.SetBody(body)
|
|
|
|
|
|
|
|
body.SetObjectPart(info.ToV2())
|
|
|
|
|
|
|
|
return resp
|
2020-09-26 07:54:03 +00:00
|
|
|
}
|
2020-12-07 17:49:47 +00:00
|
|
|
|
2024-04-22 06:43:42 +00:00
|
|
|
func ecInfoResponse(info *objectSDK.ECInfo) *objectV2.GetResponse {
|
|
|
|
resp := new(objectV2.GetResponse)
|
|
|
|
|
|
|
|
body := new(objectV2.GetResponseBody)
|
|
|
|
resp.SetBody(body)
|
|
|
|
|
|
|
|
body.SetObjectPart(info.ToV2())
|
|
|
|
|
|
|
|
return resp
|
|
|
|
}
|
|
|
|
|
2023-07-06 12:36:41 +00:00
|
|
|
func splitInfoRangeResponse(info *objectSDK.SplitInfo) *objectV2.GetRangeResponse {
|
2020-12-07 17:49:47 +00:00
|
|
|
resp := new(objectV2.GetRangeResponse)
|
|
|
|
|
|
|
|
body := new(objectV2.GetRangeResponseBody)
|
|
|
|
resp.SetBody(body)
|
|
|
|
|
|
|
|
body.SetRangePart(info.ToV2())
|
|
|
|
|
|
|
|
return resp
|
|
|
|
}
|
2020-12-08 16:18:24 +00:00
|
|
|
|
2024-05-02 11:29:59 +00:00
|
|
|
func ecInfoRangeResponse(info *objectSDK.ECInfo) *objectV2.GetRangeResponse {
|
|
|
|
resp := new(objectV2.GetRangeResponse)
|
|
|
|
|
|
|
|
body := new(objectV2.GetRangeResponseBody)
|
|
|
|
resp.SetBody(body)
|
|
|
|
|
|
|
|
body.SetRangePart(info.ToV2())
|
|
|
|
|
|
|
|
return resp
|
|
|
|
}
|
|
|
|
|
2023-07-06 12:36:41 +00:00
|
|
|
func setSplitInfoHeadResponse(info *objectSDK.SplitInfo, resp *objectV2.HeadResponse) {
|
2020-12-09 10:32:33 +00:00
|
|
|
resp.GetBody().SetHeaderPart(info.ToV2())
|
|
|
|
}
|
|
|
|
|
2024-04-22 06:43:42 +00:00
|
|
|
func setECInfoHeadResponse(info *objectSDK.ECInfo, resp *objectV2.HeadResponse) {
|
|
|
|
resp.GetBody().SetHeaderPart(info.ToV2())
|
|
|
|
}
|
|
|
|
|
2020-12-08 16:18:24 +00:00
|
|
|
func toHashResponse(typ refs.ChecksumType, res *getsvc.RangeHashRes) *objectV2.GetRangeHashResponse {
|
|
|
|
resp := new(objectV2.GetRangeHashResponse)
|
|
|
|
|
|
|
|
body := new(objectV2.GetRangeHashResponseBody)
|
|
|
|
resp.SetBody(body)
|
|
|
|
|
|
|
|
body.SetType(typ)
|
|
|
|
body.SetHashList(res.Hashes())
|
|
|
|
|
|
|
|
return resp
|
|
|
|
}
|
2020-12-09 10:32:33 +00:00
|
|
|
|
2023-07-06 12:36:41 +00:00
|
|
|
func toFullObjectHeader(hdr *objectSDK.Object) objectV2.GetHeaderPart {
|
2020-12-09 10:32:33 +00:00
|
|
|
obj := hdr.ToV2()
|
|
|
|
|
|
|
|
hs := new(objectV2.HeaderWithSignature)
|
|
|
|
hs.SetHeader(obj.GetHeader())
|
|
|
|
hs.SetSignature(obj.GetSignature())
|
|
|
|
|
|
|
|
return hs
|
|
|
|
}
|
|
|
|
|
2023-07-06 12:36:41 +00:00
|
|
|
func toShortObjectHeader(hdr *objectSDK.Object) objectV2.GetHeaderPart {
|
2020-12-09 10:32:33 +00:00
|
|
|
hdrV2 := hdr.ToV2().GetHeader()
|
|
|
|
|
|
|
|
sh := new(objectV2.ShortHeader)
|
|
|
|
sh.SetOwnerID(hdrV2.GetOwnerID())
|
|
|
|
sh.SetCreationEpoch(hdrV2.GetCreationEpoch())
|
|
|
|
sh.SetPayloadLength(hdrV2.GetPayloadLength())
|
|
|
|
sh.SetVersion(hdrV2.GetVersion())
|
|
|
|
sh.SetObjectType(hdrV2.GetObjectType())
|
2020-12-23 09:35:36 +00:00
|
|
|
sh.SetHomomorphicHash(hdrV2.GetHomomorphicHash())
|
|
|
|
sh.SetPayloadHash(hdrV2.GetPayloadHash())
|
2020-12-09 10:32:33 +00:00
|
|
|
|
|
|
|
return sh
|
|
|
|
}
|
2021-06-22 12:08:17 +00:00
|
|
|
|
2023-07-06 12:36:41 +00:00
|
|
|
func groupAddressRequestForwarder(f func(context.Context, network.Address, client.MultiAddressClient, []byte) (*objectSDK.Object, error)) getsvc.RequestForwarder {
|
|
|
|
return func(ctx context.Context, info client.NodeInfo, c client.MultiAddressClient) (*objectSDK.Object, error) {
|
2021-06-22 12:08:17 +00:00
|
|
|
var (
|
|
|
|
firstErr error
|
2023-07-06 12:36:41 +00:00
|
|
|
res *objectSDK.Object
|
2021-09-28 06:02:02 +00:00
|
|
|
|
|
|
|
key = info.PublicKey()
|
2021-06-22 12:08:17 +00:00
|
|
|
)
|
|
|
|
|
2021-09-28 04:46:10 +00:00
|
|
|
info.AddressGroup().IterateAddresses(func(addr network.Address) (stop bool) {
|
2021-06-22 12:08:17 +00:00
|
|
|
var err error
|
|
|
|
|
|
|
|
defer func() {
|
|
|
|
stop = err == nil
|
|
|
|
|
|
|
|
if stop || firstErr == nil {
|
|
|
|
firstErr = err
|
|
|
|
}
|
|
|
|
|
|
|
|
// would be nice to log otherwise
|
|
|
|
}()
|
|
|
|
|
2023-04-03 08:17:59 +00:00
|
|
|
res, err = f(ctx, addr, c, key)
|
2021-06-22 12:08:17 +00:00
|
|
|
|
|
|
|
return
|
|
|
|
})
|
|
|
|
|
|
|
|
return res, firstErr
|
|
|
|
}
|
|
|
|
}
|
2022-07-05 21:09:30 +00:00
|
|
|
|
|
|
|
func writeCurrentVersion(metaHdr *session.RequestMetaHeader) {
|
|
|
|
versionV2 := new(refs.Version)
|
|
|
|
|
|
|
|
apiVersion := versionSDK.Current()
|
|
|
|
apiVersion.WriteToV2(versionV2)
|
|
|
|
|
|
|
|
metaHdr.SetVersion(versionV2)
|
|
|
|
}
|
2022-07-07 15:02:07 +00:00
|
|
|
|
|
|
|
func checkStatus(stV2 *status.Status) error {
|
|
|
|
if !status.IsSuccess(stV2.Code()) {
|
|
|
|
st := apistatus.FromStatusV2(stV2)
|
|
|
|
return apistatus.ErrFromStatus(st)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2022-11-30 17:36:34 +00:00
|
|
|
|
|
|
|
func chunkToSend(global, local int, chunk []byte) []byte {
|
|
|
|
if global == local {
|
|
|
|
return chunk
|
|
|
|
}
|
|
|
|
|
|
|
|
if local+len(chunk) <= global {
|
|
|
|
// chunk has already been sent
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return chunk[global-local:]
|
|
|
|
}
|