Skip to content

Commit fb4e9f9

Browse files
GiteaBotwxiaoguang
andauthored
Ignore "Close" error when uploading container blob (#34620) (#34665)
Backport #34620 by wxiaoguang Co-authored-by: wxiaoguang <[email protected]>
1 parent 468d191 commit fb4e9f9

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

routers/api/packages/container/container.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,7 @@ func EndUploadBlob(ctx *context.Context) {
403403
}
404404
return
405405
}
406-
doClose := true
407-
defer func() {
408-
if doClose {
409-
uploader.Close()
410-
}
411-
}()
406+
defer uploader.Close()
412407

413408
if ctx.Req.Body != nil {
414409
if err := uploader.Append(ctx, ctx.Req.Body); err != nil {
@@ -441,11 +436,10 @@ func EndUploadBlob(ctx *context.Context) {
441436
return
442437
}
443438

444-
if err := uploader.Close(); err != nil {
445-
apiError(ctx, http.StatusInternalServerError, err)
446-
return
447-
}
448-
doClose = false
439+
// There was a strange bug: the "Close" fails with error "close .../tmp/package-upload/....: file already closed"
440+
// AFAIK there should be no other "Close" call to the uploader between NewBlobUploader and this line.
441+
// At least it's safe to call Close twice, so ignore the error.
442+
_ = uploader.Close()
449443

450444
if err := container_service.RemoveBlobUploadByID(ctx, uploader.ID); err != nil {
451445
apiError(ctx, http.StatusInternalServerError, err)

0 commit comments

Comments
 (0)