[lxc-devel] [lxd/master] shared/simplestreams: Only write cache if configured

stgraber on Github lxc-bot at linuxcontainers.org
Thu Dec 12 17:13:04 UTC 2019


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/20191212/ebcf31d1/attachment.bin>
-------------- next part --------------
From b7bb882ff3aac6f79ef94652af7fef83f6d83411 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 12 Dec 2019 12:12:40 -0500
Subject: [PATCH] shared/simplestreams: Only write cache if configured
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>
---
 shared/simplestreams/simplestreams.go | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/shared/simplestreams/simplestreams.go b/shared/simplestreams/simplestreams.go
index 6f3a189542..11984de5ec 100644
--- a/shared/simplestreams/simplestreams.go
+++ b/shared/simplestreams/simplestreams.go
@@ -134,9 +134,11 @@ func (s *SimpleStreams) cachedDownload(path string) ([]byte, error) {
 	}
 
 	// Attempt to store in cache
-	cacheName := filepath.Join(s.cachePath, fileName)
-	os.Remove(cacheName)
-	ioutil.WriteFile(cacheName, body, 0644)
+	if s.cachePath != "" {
+		cacheName := filepath.Join(s.cachePath, fileName)
+		os.Remove(cacheName)
+		ioutil.WriteFile(cacheName, body, 0644)
+	}
 
 	return body, nil
 }


More information about the lxc-devel mailing list