Ignore "Close" error when uploading container blob (#34620)

pull/34652/head^2
wxiaoguang 2025-06-09 15:06:21 +08:00 committed by GitHub
parent 6d0b24064a
commit 7a59f5a825
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 11 deletions

View File

@ -403,12 +403,7 @@ func EndUploadBlob(ctx *context.Context) {
} }
return return
} }
doClose := true defer uploader.Close()
defer func() {
if doClose {
uploader.Close()
}
}()
if ctx.Req.Body != nil { if ctx.Req.Body != nil {
if err := uploader.Append(ctx, ctx.Req.Body); err != nil { if err := uploader.Append(ctx, ctx.Req.Body); err != nil {
@ -441,11 +436,10 @@ func EndUploadBlob(ctx *context.Context) {
return return
} }
if err := uploader.Close(); err != nil { // There was a strange bug: the "Close" fails with error "close .../tmp/package-upload/....: file already closed"
apiError(ctx, http.StatusInternalServerError, err) // AFAIK there should be no other "Close" call to the uploader between NewBlobUploader and this line.
return // At least it's safe to call Close twice, so ignore the error.
} _ = uploader.Close()
doClose = false
if err := container_service.RemoveBlobUploadByID(ctx, uploader.ID); err != nil { if err := container_service.RemoveBlobUploadByID(ctx, uploader.ID); err != nil {
apiError(ctx, http.StatusInternalServerError, err) apiError(ctx, http.StatusInternalServerError, err)