summaryrefslogtreecommitdiff
path: root/pkg/api/handlers
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-12-15 22:23:09 +0000
committerGitHub <noreply@github.com>2020-12-15 22:23:09 +0000
commit66e979a892df7dc820e6ce7ada0e3a34619c172f (patch)
treede43ec5034677ad2fac6e7ec3866fe66fd0de68d /pkg/api/handlers
parente689503fd6995fa45d990fef6ad7de425c1cbcba (diff)
parentaf36d444a577f08df7182b3901340a591d94eb2f (diff)
downloadpodman-66e979a892df7dc820e6ce7ada0e3a34619c172f.tar.gz
podman-66e979a892df7dc820e6ce7ada0e3a34619c172f.tar.bz2
podman-66e979a892df7dc820e6ce7ada0e3a34619c172f.zip
Merge pull request #8723 from matejvasek/cleanup-tmp-file
Clean up temporary file.
Diffstat (limited to 'pkg/api/handlers')
-rw-r--r--pkg/api/handlers/compat/images.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go
index a51dd8ed3..dc72500e4 100644
--- a/pkg/api/handlers/compat/images.go
+++ b/pkg/api/handlers/compat/images.go
@@ -22,6 +22,7 @@ import (
"github.com/gorilla/schema"
"github.com/opencontainers/go-digest"
"github.com/pkg/errors"
+ "github.com/sirupsen/logrus"
)
// 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"))
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 {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "failed to write temporary file"))
return