Skip to content

Commit

Permalink
Merge pull request #24277 from mi4r/dev/mi4r/ImagesImportFix
Browse files Browse the repository at this point in the history
api: Move close function in condition body
  • Loading branch information
openshift-merge-bot[bot] authored Nov 7, 2024
2 parents cbb5d7f + 9f5bbec commit f8ac02d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/api/handlers/libpod/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,14 +403,17 @@ func ImagesImport(w http.ResponseWriter, r *http.Request) {
return
}
defer os.Remove(tmpfile.Name())
defer tmpfile.Close()

if _, err := io.Copy(tmpfile, r.Body); err != nil && err != io.EOF {
utils.Error(w, http.StatusInternalServerError, fmt.Errorf("unable to write archive to temporary file: %w", err))
tmpfile.Close()
return
}

tmpfile.Close()
if err := tmpfile.Close(); err != nil {
utils.Error(w, http.StatusInternalServerError, fmt.Errorf("unable to close tempfile: %w", err))
return
}
source = tmpfile.Name()
}

Expand Down

1 comment on commit f8ac02d

@packit-as-a-service
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

podman-next COPR build failed. @containers/packit-build please check.

Please sign in to comment.