From 4909a08d53b5f1a920006642ae63fe99c240197c Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Thu, 17 Aug 2023 20:58:52 +0300 Subject: [PATCH] cli, node: Do not treat `EOF` as a network error That is the only possible way `client.Client` can say stream has been closed (because of internal logic, not the network/unexpected errors) in the current API. It returned `bool` in the previous versions. Closes #2513, closes #2502. Signed-off-by: Pavel Karpy --- cmd/neofs-cli/internal/client/client.go | 3 ++- pkg/services/object/internal/client/client.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/neofs-cli/internal/client/client.go b/cmd/neofs-cli/internal/client/client.go index 59629937fc..446aa5d147 100644 --- a/cmd/neofs-cli/internal/client/client.go +++ b/cmd/neofs-cli/internal/client/client.go @@ -3,6 +3,7 @@ package internal import ( "bytes" "context" + "errors" "fmt" "io" @@ -439,7 +440,7 @@ func PutObject(ctx context.Context, prm PutObjectPrm) (*PutObjectRes, error) { buf := make([]byte, sz) _, err = io.CopyBuffer(wrt, prm.rdr, buf) - if err != nil { + if err != nil && !errors.Is(err, io.EOF) { return nil, fmt.Errorf("copy data into object stream: %w", err) } } diff --git a/pkg/services/object/internal/client/client.go b/pkg/services/object/internal/client/client.go index 18ff3a9a54..fca466c12b 100644 --- a/pkg/services/object/internal/client/client.go +++ b/pkg/services/object/internal/client/client.go @@ -409,7 +409,7 @@ func PutObject(prm PutObjectPrm) (*PutObjectRes, error) { } _, err = w.Write(prm.obj.Payload()) - if err != nil { + if err != nil && !errors.Is(err, io.EOF) { return nil, fmt.Errorf("write object payload into stream: %w", err) }