From 5be4d413b0487285a7b293e27b4b782088672de9 Mon Sep 17 00:00:00 2001 From: Michal Niewrzal Date: Fri, 20 Nov 2020 13:37:54 +0100 Subject: [PATCH] satellite/metainfo: set PlainSize for inline segment Plain size is required by metabase implementation. Change-Id: I6739744bff4ce485e0066f2a49acdf38560d31fb --- go.mod | 2 +- go.sum | 4 ++-- satellite/metainfo/metainfo.go | 15 ++++++++++----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index f70be6e8a..73c409b04 100644 --- a/go.mod +++ b/go.mod @@ -42,7 +42,7 @@ require ( golang.org/x/sys v0.0.0-20200929083018-4d22bbb62b3c golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e google.golang.org/api v0.20.0 // indirect - storj.io/common v0.0.0-20201119120404-37756b80ef3b + storj.io/common v0.0.0-20201119173627-1cdb53f04fad storj.io/drpc v0.0.16 storj.io/monkit-jaeger v0.0.0-20200518165323-80778fc3f91b storj.io/private v0.0.0-20201026143115-bc926bfa3bca diff --git a/go.sum b/go.sum index 4ed88647c..8fc2bbd11 100644 --- a/go.sum +++ b/go.sum @@ -906,8 +906,8 @@ storj.io/common v0.0.0-20200424175742-65ac59022f4f/go.mod h1:pZyXiIE7bGETIRXtfs0 storj.io/common v0.0.0-20201026135900-1aaeec90670b/go.mod h1:GqdmNf3fLm2UZX/7Zr0BLFCJ4gFjgm6eHrk/fnmr5jQ= storj.io/common v0.0.0-20201106104920-372a344bdd45 h1:pv552R7MiRA8VLQC4qXczLjbl2Qb/MNyus2E9NBSXgI= storj.io/common v0.0.0-20201106104920-372a344bdd45/go.mod h1:ZkQZup2jpFZvvTgz+yPc7K4Vr4bBHM8AA66P57MZkjk= -storj.io/common v0.0.0-20201119120404-37756b80ef3b h1:tYz4nbxG7gbkZ1MTHKhrS/IDTOKXSCHunWEShWxvliI= -storj.io/common v0.0.0-20201119120404-37756b80ef3b/go.mod h1:Cl1rpX3ZfVpOLw0Al6nRGwPbw2DwwXFF5J/63Nf4Sd8= +storj.io/common v0.0.0-20201119173627-1cdb53f04fad h1:DTQYc1yH+XwOFx8Dy6CBhLG9eCmYJ5YuK/eRIOxX03A= +storj.io/common v0.0.0-20201119173627-1cdb53f04fad/go.mod h1:Cl1rpX3ZfVpOLw0Al6nRGwPbw2DwwXFF5J/63Nf4Sd8= storj.io/drpc v0.0.11/go.mod h1:TiFc2obNjL9/3isMW1Rpxjy8V9uE0B2HMeMFGiiI7Iw= storj.io/drpc v0.0.11/go.mod h1:TiFc2obNjL9/3isMW1Rpxjy8V9uE0B2HMeMFGiiI7Iw= storj.io/drpc v0.0.14 h1:GCBdymTt1BRw4oHmmUZZlxYXLVRxxYj6x3Ivide2J+I= diff --git a/satellite/metainfo/metainfo.go b/satellite/metainfo/metainfo.go index 01358d670..45f76da57 100644 --- a/satellite/metainfo/metainfo.go +++ b/satellite/metainfo/metainfo.go @@ -1434,7 +1434,9 @@ func (endpoint *Endpoint) commitSegment(ctx context.Context, req *pb.SegmentComm EncryptedKey: req.EncryptedKey, EncryptedKeyNonce: req.EncryptedKeyNonce[:], - EncryptedSize: int32(req.SizeEncryptedData), // TODO verify int32 vs int64 + EncryptedSize: int32(req.SizeEncryptedData), // TODO incompatible types int32 vs int64 + PlainSize: int32(req.PlainSize), // TODO incompatible types int32 vs int64 + Position: metabase.SegmentPosition{ Part: uint32(segmentID.PartNumber), Index: uint32(segmentID.Index), @@ -1442,11 +1444,11 @@ func (endpoint *Endpoint) commitSegment(ctx context.Context, req *pb.SegmentComm RootPieceID: segmentID.RootPieceId, Redundancy: rs, Pieces: pieces, - - PlainSize: int32(req.PlainSize), }) - if err != nil { + if metabase.ErrInvalidRequest.Has(err) { + return nil, nil, rpcstatus.Error(rpcstatus.InvalidArgument, err.Error()) + } endpoint.log.Error("internal", zap.Error(err)) return nil, nil, rpcstatus.Error(rpcstatus.Internal, err.Error()) } @@ -1536,11 +1538,14 @@ func (endpoint *Endpoint) makeInlineSegment(ctx context.Context, req *pb.Segment Index: uint32(req.Position.Index), }, - PlainSize: 1, // TODO + PlainSize: int32(req.PlainSize), // TODO incompatible types int32 vs int64 InlineData: req.EncryptedInlineData, }) if err != nil { + if metabase.ErrInvalidRequest.Has(err) { + return nil, nil, rpcstatus.Error(rpcstatus.InvalidArgument, err.Error()) + } endpoint.log.Error("internal", zap.Error(err)) return nil, nil, rpcstatus.Error(rpcstatus.Internal, err.Error()) }