[lxc-devel] [lxd/master] Cleanup leftover temp file

stgraber on Github lxc-bot at linuxcontainers.org
Sat Nov 26 22:28:25 UTC 2016


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/20161126/1efdf7e4/attachment.bin>
-------------- next part --------------
From 0b84dd554b033c901b9fb0e357e6614ee3ebc631 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Sat, 26 Nov 2016 17:22:53 -0500
Subject: [PATCH] Cleanup leftover temp file
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/container_file.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lxd/container_file.go b/lxd/container_file.go
index e682061..7e9d20b 100644
--- a/lxd/container_file.go
+++ b/lxd/container_file.go
@@ -52,6 +52,7 @@ func containerFileGet(c container, path string, r *http.Request) Response {
 	// Pull the file from the container
 	uid, gid, mode, type_, dirEnts, err := c.FilePull(path, temp.Name())
 	if err != nil {
+		os.Remove(temp.Name())
 		return SmartError(err)
 	}
 
@@ -71,8 +72,10 @@ func containerFileGet(c container, path string, r *http.Request) Response {
 
 		return FileResponse(r, files, headers, true)
 	} else if type_ == "directory" {
+		os.Remove(temp.Name())
 		return SyncResponseHeaders(true, dirEnts, headers)
 	} else {
+		os.Remove(temp.Name())
 		return InternalError(fmt.Errorf("bad file type %s", type_))
 	}
 }


More information about the lxc-devel mailing list