[lxc-devel] [lxd/master] lxc/image: Fix regression in exported filename
stgraber on Github
lxc-bot at linuxcontainers.org
Thu Sep 28 20:43:06 UTC 2017
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 370 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170928/f8b51ebf/attachment.bin>
-------------- next part --------------
From 6a45ae78cd95199024c76c91f0307233fd36c02b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 28 Sep 2017 16:42:29 -0400
Subject: [PATCH] lxc/image: Fix regression in exported filename
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Closes #3869
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxc/image.go | 10 ++++++++++
test/suites/basic.sh | 4 ++--
test/suites/remote.sh | 4 ++--
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/lxc/image.go b/lxc/image.go
index ef6593231..286bb4681 100644
--- a/lxc/image.go
+++ b/lxc/image.go
@@ -945,6 +945,16 @@ func (c *imageCmd) run(conf *config.Config, args []string) error {
return err
}
}
+ } else if resp.RootfsSize == 0 && len(args) > 2 {
+ if resp.MetaName != "" {
+ extension := strings.SplitN(resp.MetaName, ".", 2)[1]
+ err := os.Rename(targetMeta, fmt.Sprintf("%s.%s", targetMeta, extension))
+ if err != nil {
+ os.Remove(targetMeta)
+ progress.Done("")
+ return err
+ }
+ }
}
progress.Done(i18n.G("Image exported successfully!"))
diff --git a/test/suites/basic.sh b/test/suites/basic.sh
index b8d84f193..f51bc378b 100644
--- a/test/suites/basic.sh
+++ b/test/suites/basic.sh
@@ -55,8 +55,8 @@ test_basic_usage() {
# Test custom filename for image export
lxc image export testimage "${LXD_DIR}/foo"
- [ "${sum}" = "$(sha256sum "${LXD_DIR}/foo" | cut -d' ' -f1)" ]
- rm "${LXD_DIR}/foo"
+ [ "${sum}" = "$(sha256sum "${LXD_DIR}/foo.tar.xz" | cut -d' ' -f1)" ]
+ rm "${LXD_DIR}/foo.tar.xz"
# Test image export with a split image.
diff --git a/test/suites/remote.sh b/test/suites/remote.sh
index 301de89a5..24943a990 100644
--- a/test/suites/remote.sh
+++ b/test/suites/remote.sh
@@ -84,8 +84,8 @@ test_remote_usage() {
lxc_remote image export localhost:testimage "${LXD_DIR}/foo"
lxc_remote image delete localhost:testimage
- sum=$(sha256sum "${LXD_DIR}/foo" | cut -d' ' -f1)
- lxc_remote image import "${LXD_DIR}/foo" localhost: --public
+ sum=$(sha256sum "${LXD_DIR}/foo.tar.xz" | cut -d' ' -f1)
+ lxc_remote image import "${LXD_DIR}/foo.tar.xz" localhost: --public
lxc_remote image alias create localhost:testimage "${sum}"
lxc_remote image delete "lxd2:${sum}" || true
More information about the lxc-devel
mailing list