From 8278d3875ba01360d8f1cce1f1c921c9ea4b234a Mon Sep 17 00:00:00 2001 From: seiuneko <25706824+seiuneko@users.noreply.github.com> Date: Sun, 14 Jul 2024 20:59:24 +0800 Subject: [PATCH] fix: ignore os.ErrClosed error on repeated FileStream close operations (#6762) Also resolves the issue where S3 PutObject returns a 500 status code. --- internal/stream/stream.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/stream/stream.go b/internal/stream/stream.go index 40482f45..2c9543c1 100644 --- a/internal/stream/stream.go +++ b/internal/stream/stream.go @@ -51,7 +51,11 @@ func (f *FileStream) IsForceStreamUpload() bool { func (f *FileStream) Close() error { var err1, err2 error + err1 = f.Closers.Close() + if errors.Is(err1, os.ErrClosed) { + err1 = nil + } if f.tmpFile != nil { err2 = os.RemoveAll(f.tmpFile.Name()) if err2 != nil {