mirror of
https://github.com/containers/podman.git
synced 2025-06-20 09:03:43 +08:00
Clean up temporary file.
Signed-off-by: Matej Vasek <mvasek@redhat.com>
This commit is contained in:
@ -22,6 +22,7 @@ import (
|
|||||||
"github.com/gorilla/schema"
|
"github.com/gorilla/schema"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// mergeNameAndTagOrDigest creates an image reference as string from the
|
// mergeNameAndTagOrDigest creates an image reference as string from the
|
||||||
@ -386,6 +387,12 @@ func LoadImages(w http.ResponseWriter, r *http.Request) {
|
|||||||
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "failed to create tempfile"))
|
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "failed to create tempfile"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
err := os.Remove(f.Name())
|
||||||
|
if err != nil {
|
||||||
|
logrus.Errorf("Failed to remove temporary file: %v.", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
if err := SaveFromBody(f, r); err != nil {
|
if err := SaveFromBody(f, r); err != nil {
|
||||||
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "failed to write temporary file"))
|
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "failed to write temporary file"))
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user