[lxc-devel] [lxd/master] lxd/images: Fix private image copy with partial fp
stgraber on Github
lxc-bot at linuxcontainers.org
Wed Aug 30 18:39:58 UTC 2017
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/20170830/1513904e/attachment.bin>
-------------- next part --------------
From 4310ac962db40723a74529b00b4cd3f8ea94451d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 30 Aug 2017 14:39:16 -0400
Subject: [PATCH] lxd/images: Fix private image copy with partial fp
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/daemon_images.go | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/lxd/daemon_images.go b/lxd/daemon_images.go
index d76e3209c..06bb5fd4a 100644
--- a/lxd/daemon_images.go
+++ b/lxd/daemon_images.go
@@ -522,6 +522,23 @@ func (d *Daemon) ImageDownload(op *operation, server string, protocol string, ce
// Image is in the DB now, don't wipe on-disk files on failure
failure = false
+ // Check if the image path changed (private images)
+ newDestName := filepath.Join(destDir, fp)
+ if newDestName != destName {
+ err = shared.FileMove(destName, newDestName)
+ if err != nil {
+ return nil, err
+ }
+
+ if shared.PathExists(destName + ".rootfs") {
+ err = shared.FileMove(destName+".rootfs", newDestName+".rootfs")
+ if err != nil {
+ return nil, err
+ }
+ }
+ }
+
+ // Record the image source
if alias != fp {
id, _, err := db.ImageGet(d.db, fp, false, true)
if err != nil {
More information about the lxc-devel
mailing list