Skip to content

Commit

Permalink
fix: ignore os.ErrClosed error on repeated FileStream close operations (
Browse files Browse the repository at this point in the history
AlistGo#6762)

Also resolves the issue where S3 PutObject returns a 500 status code.
  • Loading branch information
seiuneko authored and Three-taile-dragon committed Sep 26, 2024
1 parent 3e0cfbe commit bdff5f7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/stream/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit bdff5f7

Please sign in to comment.