Skip to content

Ignore "Close" error when uploading container blob #34620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions routers/api/packages/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down