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