[lxc-devel] [lxd/master] lxd/images: Add missing cleanup code
stgraber on Github
lxc-bot at linuxcontainers.org
Fri Aug 24 21:30:56 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180824/80de48b9/attachment.bin>
-------------- next part --------------
From 199b8f8cd646e941489ff8ead9b0baaab577b219 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 24 Aug 2018 17:30:35 -0400
Subject: [PATCH] lxd/images: Add missing cleanup code
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/images.go | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lxd/images.go b/lxd/images.go
index 57a83a2fb2..1724b0b98b 100644
--- a/lxd/images.go
+++ b/lxd/images.go
@@ -645,8 +645,10 @@ func imagesPost(d *Daemon, r *http.Request) Response {
err = decoder.Decode(&req)
if err != nil {
if r.Header.Get("Content-Type") == "application/json" {
+ cleanup(builddir, post)
return BadRequest(err)
}
+
imageUpload = true
}
@@ -663,9 +665,12 @@ func imagesPost(d *Daemon, r *http.Request) Response {
r.Body = post
response, err := ForwardedResponseIfContainerIsRemote(d, r, name)
if err != nil {
+ cleanup(builddir, post)
return SmartError(err)
}
+
if response != nil {
+ cleanup(builddir, post)
return response
}
}
@@ -728,6 +733,7 @@ func imagesPost(d *Daemon, r *http.Request) Response {
op, err := operationCreate(d.cluster, operationClassTask, db.OperationImageDownload, nil, nil, run, nil, nil)
if err != nil {
+ cleanup(builddir, post)
return InternalError(err)
}
More information about the lxc-devel
mailing list