From 1e1bd3afd90c9a55cef260fdb2a26e3dd6e68de3 Mon Sep 17 00:00:00 2001 From: jiuker <2818723467@qq.com> Date: Wed, 21 Aug 2024 20:20:54 +0800 Subject: [PATCH] use io.NopCloser replace closeWrapper (#20287) --- cmd/bitrot-streaming.go | 8 +------- cmd/xl-storage.go | 8 -------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/cmd/bitrot-streaming.go b/cmd/bitrot-streaming.go index edf3f1106..d707c70e2 100644 --- a/cmd/bitrot-streaming.go +++ b/cmd/bitrot-streaming.go @@ -141,13 +141,7 @@ func (b *streamingBitrotReader) Close() error { } if closer, ok := b.rc.(io.Closer); ok { // drain the body for connection reuse at network layer. - xhttp.DrainBody(struct { - io.Reader - io.Closer - }{ - Reader: b.rc, - Closer: closeWrapper(func() error { return nil }), - }) + xhttp.DrainBody(io.NopCloser(b.rc)) return closer.Close() } return nil diff --git a/cmd/xl-storage.go b/cmd/xl-storage.go index 9ae4a356b..63b3ff488 100644 --- a/cmd/xl-storage.go +++ b/cmd/xl-storage.go @@ -2079,14 +2079,6 @@ func (s *xlStorage) ReadFileStream(ctx context.Context, volume, path string, off return &sendFileReader{Reader: io.LimitReader(file, length), Closer: file}, nil } -// closeWrapper converts a function to an io.Closer -type closeWrapper func() error - -// Close calls the wrapped function. -func (c closeWrapper) Close() error { - return c() -} - // CreateFile - creates the file. func (s *xlStorage) CreateFile(ctx context.Context, origvolume, volume, path string, fileSize int64, r io.Reader) (err error) { if origvolume != "" {