From 9ebcb6b9645f59b0250fc17831cb91c4142cd514 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Mon, 22 Aug 2022 18:00:13 +0300 Subject: [PATCH] [#188] Update SDK to avoid panic on go1.19 Signed-off-by: Denis Kirillov --- downloader/download.go | 2 +- downloader/head.go | 8 ++++++-- go.mod | 12 ++++++------ go.sum | 17 ++++++++++------- uploader/upload.go | 4 ++-- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/downloader/download.go b/downloader/download.go index f43d93d..e34e3b7 100644 --- a/downloader/download.go +++ b/downloader/download.go @@ -368,7 +368,7 @@ func (d *Downloader) byAttribute(c *fasthttp.RequestCtx, f func(request, *pool.P f(*d.newRequest(c, log), d.pool, addrObj) } -func (d *Downloader) search(c *fasthttp.RequestCtx, cid *cid.ID, key, val string, op object.SearchMatchType) (*pool.ResObjectSearch, error) { +func (d *Downloader) search(c *fasthttp.RequestCtx, cid *cid.ID, key, val string, op object.SearchMatchType) (pool.ResObjectSearch, error) { filters := object.NewSearchFilters() filters.AddRootFilter() filters.AddFilter(key, val, op) diff --git a/downloader/head.go b/downloader/head.go index bcddd08..eafed21 100644 --- a/downloader/head.go +++ b/downloader/head.go @@ -72,7 +72,7 @@ func (r request) headObject(clnt *pool.Pool, objectAddress oid.Address) { } } - idsToResponse(&r.Response, obj) + idsToResponse(&r.Response, &obj) if len(contentType) == 0 { contentType, _, err = readContentType(obj.PayloadSize(), func(sz uint64) (io.Reader, error) { @@ -83,7 +83,11 @@ func (r request) headObject(clnt *pool.Pool, objectAddress oid.Address) { prmRange.UseBearer(*btoken) } - return clnt.ObjectRange(r.appCtx, prmRange) + resObj, err := clnt.ObjectRange(r.appCtx, prmRange) + if err != nil { + return nil, err + } + return &resObj, nil }) if err != nil && err != io.EOF { r.handleNeoFSErr(err, start) diff --git a/go.mod b/go.mod index 89abe20..ba8b37d 100644 --- a/go.mod +++ b/go.mod @@ -4,11 +4,10 @@ go 1.17 require ( github.com/fasthttp/router v1.4.1 - github.com/nspcc-dev/neo-go v0.99.1-pre.0.20220714084516-54849ef3e58e - github.com/nspcc-dev/neofs-api-go/v2 v2.13.0 - github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.5.0.20220725101411-90f1cc7a1a77 + github.com/nspcc-dev/neo-go v0.99.1 + github.com/nspcc-dev/neofs-api-go/v2 v2.13.2-0.20220818094951-98db3fa28419 + github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.6.0.20220824140410-7537fa0decc5 github.com/prometheus/client_golang v1.11.0 - github.com/prometheus/common v0.30.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.8.1 github.com/stretchr/testify v1.7.0 @@ -56,9 +55,9 @@ require ( github.com/mr-tron/base58 v1.2.0 // indirect github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22 // indirect github.com/nspcc-dev/hrw v1.0.9 // indirect - github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220713145417-4f184498bc42 // indirect + github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220727202624-6c7a401f776a // indirect github.com/nspcc-dev/neofs-contract v0.15.3 // indirect - github.com/nspcc-dev/neofs-crypto v0.3.0 // indirect + github.com/nspcc-dev/neofs-crypto v0.4.0 // indirect github.com/nspcc-dev/rfc6979 v0.2.0 // indirect github.com/nspcc-dev/tzhash v1.6.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect @@ -68,6 +67,7 @@ require ( github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.2.0 // indirect + github.com/prometheus/common v0.30.0 // indirect github.com/prometheus/procfs v0.7.3 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/savsgio/gotils v0.0.0-20210617111740-97865ed5a873 // indirect diff --git a/go.sum b/go.sum index ad66064..5929f56 100644 --- a/go.sum +++ b/go.sum @@ -740,24 +740,27 @@ github.com/nspcc-dev/hrw v1.0.9 h1:17VcAuTtrstmFppBjfRiia4K2wA/ukXZhLFS8Y8rz5Y= github.com/nspcc-dev/hrw v1.0.9/go.mod h1:l/W2vx83vMQo6aStyx2AuZrJ+07lGv2JQGlVkPG06MU= github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1:pPYwPZ2ks+uMnlRLUyXOpLieaDQSEaf4NM3zHVbRjmg= github.com/nspcc-dev/neo-go v0.98.0/go.mod h1:E3cc1x6RXSXrJb2nDWXTXjnXk3rIqVN8YdFyWv+FrqM= -github.com/nspcc-dev/neo-go v0.99.1-pre.0.20220714084516-54849ef3e58e h1:sjl8sniYkjoOsD8F+wzkpRfm9RzZSLQlh5Z/SMyf4A8= github.com/nspcc-dev/neo-go v0.99.1-pre.0.20220714084516-54849ef3e58e/go.mod h1:/y5Sl8p3YheTygriBtCCMWKkDOek8HcvSo5ds2rJtKI= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220713145417-4f184498bc42 h1:Krhg2cD5mqvC+lin7irw6hj0M+x4ZOZrRGzrZQB+wcQ= +github.com/nspcc-dev/neo-go v0.99.1 h1:/dlDVVCqlmazusIu+Emd4TlwxjIOpNNU5ob7bwUH6Qk= +github.com/nspcc-dev/neo-go v0.99.1/go.mod h1:wvKMQXlE/M3eqtN0KIi1MjkEVTvYIJRrOMnJtqEkCxs= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220713145417-4f184498bc42/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220727202624-6c7a401f776a h1:ND5lYt9/cybrbS6/DVX0398a4ilt4/xE/QtEaOzJSGY= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220727202624-6c7a401f776a/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= github.com/nspcc-dev/neofs-api-go/v2 v2.11.1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= -github.com/nspcc-dev/neofs-api-go/v2 v2.13.0 h1:7BcBiSjmWqJx0SPFlGRYt9ZFbMjucRIz9+Mv8UBLeq8= -github.com/nspcc-dev/neofs-api-go/v2 v2.13.0/go.mod h1:73j09Xa7I2zQbM3HCvAHnDHPYiiWnEHa1d6Z6RDMBLU= +github.com/nspcc-dev/neofs-api-go/v2 v2.13.2-0.20220818094951-98db3fa28419 h1:NFj8D0UYfHzvC+gIhK7yIUOyEcZi21caQsuYVbJGrVU= +github.com/nspcc-dev/neofs-api-go/v2 v2.13.2-0.20220818094951-98db3fa28419/go.mod h1:NAaDfOnFWIbAFkTj7pNQ+cknVue0JbdeRT9QQaeBCEY= github.com/nspcc-dev/neofs-contract v0.15.3 h1:7+NwyTtxFAnIevz0hR/XxQf6R2Ej2scjVR2bnnJnhBM= github.com/nspcc-dev/neofs-contract v0.15.3/go.mod h1:BXVZUZUJxrmmDETglXHI8+5DSgn84B9y5DoSWqEjYCs= github.com/nspcc-dev/neofs-crypto v0.2.0/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA= github.com/nspcc-dev/neofs-crypto v0.2.3/go.mod h1:8w16GEJbH6791ktVqHN9YRNH3s9BEEKYxGhlFnp0cDw= -github.com/nspcc-dev/neofs-crypto v0.3.0 h1:zlr3pgoxuzrmGCxc5W8dGVfA9Rro8diFvVnBg0L4ifM= github.com/nspcc-dev/neofs-crypto v0.3.0/go.mod h1:8w16GEJbH6791ktVqHN9YRNH3s9BEEKYxGhlFnp0cDw= +github.com/nspcc-dev/neofs-crypto v0.4.0 h1:5LlrUAM5O0k1+sH/sktBtrgfWtq1pgpDs09fZo+KYi4= +github.com/nspcc-dev/neofs-crypto v0.4.0/go.mod h1:6XJ8kbXgOfevbI2WMruOtI+qUJXNwSGM/E9eClXxPHs= github.com/nspcc-dev/neofs-sdk-go v0.0.0-20211201182451-a5b61c4f6477/go.mod h1:dfMtQWmBHYpl9Dez23TGtIUKiFvCIxUZq/CkSIhEpz4= github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220113123743-7f3162110659/go.mod h1:/jay1lr3w7NQd/VDBkEhkJmDmyPNsu4W+QV2obsUV40= -github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.5.0.20220725101411-90f1cc7a1a77 h1:C8QL3pUN/QZ7OdXONEV2FQ+JamXoBbovvZiylWOCfBo= -github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.5.0.20220725101411-90f1cc7a1a77/go.mod h1:39SbCo+QUI0WJS47VsW4SCWhOwnJNpQSy8rGEG/b5vc= +github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.6.0.20220824140410-7537fa0decc5 h1:BkjgenUQeXnMnbvdpyn8tOoxZmaeKOsN6EEq8wF9Xnw= +github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.6.0.20220824140410-7537fa0decc5/go.mod h1:BQPxy2sOURSegZJVnrwYDagPtKI3H1Ctc7e0yS0xHvk= github.com/nspcc-dev/rfc6979 v0.1.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso= github.com/nspcc-dev/rfc6979 v0.2.0 h1:3e1WNxrN60/6N0DW7+UYisLeZJyfqZTNOjeV/toYvOE= github.com/nspcc-dev/rfc6979 v0.2.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso= diff --git a/uploader/upload.go b/uploader/upload.go index d6b06c8..4c1172c 100644 --- a/uploader/upload.go +++ b/uploader/upload.go @@ -59,7 +59,7 @@ func New(ctx context.Context, params *utils.AppParams, enableDefaultTimestamp bo func (u *Uploader) Upload(c *fasthttp.RequestCtx) { var ( file MultipartFile - idObj *oid.ID + idObj oid.ID addr oid.Address scid, _ = c.UserValue("cid").(string) log = u.log.With(zap.String("cid", scid)) @@ -157,7 +157,7 @@ func (u *Uploader) Upload(c *fasthttp.RequestCtx) { return } - addr.SetObject(*idObj) + addr.SetObject(idObj) addr.SetContainer(*idCnr) // Try to return the response, otherwise, if something went wrong, throw an error.