[lxc-devel] [lxd/master] lxc/file: Fix pushing files to remote

stgraber on Github lxc-bot at linuxcontainers.org
Tue Apr 3 14:30:48 UTC 2018


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/20180403/00c3735e/attachment.bin>
-------------- next part --------------
From 46df12d9c75a8d560d0cde04d517feda30a65c57 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 3 Apr 2018 10:29:53 -0400
Subject: [PATCH] lxc/file: Fix pushing files to remote
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #4394

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxc/file.go              | 9 ++++-----
 test/suites/filemanip.sh | 5 ++---
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/lxc/file.go b/lxc/file.go
index d441af234..b8f0f4ed4 100644
--- a/lxc/file.go
+++ b/lxc/file.go
@@ -351,7 +351,6 @@ func (c *cmdFilePush) Run(cmd *cobra.Command, args []string) error {
 	if len(pathSpec) != 2 {
 		return fmt.Errorf(i18n.G("Invalid target %s"), target)
 	}
-	container := pathSpec[0]
 
 	targetIsDir := strings.HasSuffix(target, "/")
 	// re-add leading / that got stripped by the SplitN
@@ -413,7 +412,7 @@ func (c *cmdFilePush) Run(cmd *cobra.Command, args []string) error {
 
 			mode, uid, gid := shared.GetOwnerMode(finfo)
 
-			err = c.file.recursiveMkdir(resource.server, container, targetPath, &mode, int64(uid), int64(gid))
+			err = c.file.recursiveMkdir(resource.server, resource.name, targetPath, &mode, int64(uid), int64(gid))
 			if err != nil {
 				return err
 			}
@@ -421,7 +420,7 @@ func (c *cmdFilePush) Run(cmd *cobra.Command, args []string) error {
 
 		// Transfer the files
 		for _, fname := range sourcefilenames {
-			err := c.file.recursivePushFile(resource.server, container, fname, targetPath)
+			err := c.file.recursivePushFile(resource.server, resource.name, fname, targetPath)
 			if err != nil {
 				return err
 			}
@@ -488,7 +487,7 @@ func (c *cmdFilePush) Run(cmd *cobra.Command, args []string) error {
 				}
 			}
 
-			err = c.file.recursiveMkdir(resource.server, container, path.Dir(fpath), nil, int64(uid), int64(gid))
+			err = c.file.recursiveMkdir(resource.server, resource.name, path.Dir(fpath), nil, int64(uid), int64(gid))
 			if err != nil {
 				return err
 			}
@@ -534,7 +533,7 @@ func (c *cmdFilePush) Run(cmd *cobra.Command, args []string) error {
 		args.Type = "file"
 
 		logger.Infof("Pushing %s to %s (%s)", f.Name(), fpath, args.Type)
-		err = resource.server.CreateContainerFile(container, fpath, args)
+		err = resource.server.CreateContainerFile(resource.name, fpath, args)
 		if err != nil {
 			return err
 		}
diff --git a/test/suites/filemanip.sh b/test/suites/filemanip.sh
index 26f238de7..b5bf5bb7a 100644
--- a/test/suites/filemanip.sh
+++ b/test/suites/filemanip.sh
@@ -48,7 +48,6 @@ test_filemanip() {
   rm -rf "${TEST_DIR}/dest"
 
   # Check that file permissions are not applied to intermediate directories
-
   lxc file push -p --mode=400 "${TEST_DIR}"/source/foo \
       filemanip/tmp/ptest/d1/d2/foo
 
@@ -100,8 +99,8 @@ test_filemanip() {
   [ "$(stat -c "%g" "${TEST_DIR}"/dest/source)" = "$(id -g)" ]
   [ "$(stat -c "%a" "${TEST_DIR}"/dest/source)" = "755" ]
 
-  lxc file push -p "${TEST_DIR}"/source/foo filemanip/tmp/this/is/a/nonexistent/directory/
-  lxc file pull filemanip/tmp/this/is/a/nonexistent/directory/foo "${TEST_DIR}"
+  lxc file push -p "${TEST_DIR}"/source/foo local:filemanip/tmp/this/is/a/nonexistent/directory/
+  lxc file pull local:filemanip/tmp/this/is/a/nonexistent/directory/foo "${TEST_DIR}"
   [ "$(cat "${TEST_DIR}"/foo)" = "foo" ]
 
   lxc file push -p "${TEST_DIR}"/source/foo filemanip/.


More information about the lxc-devel mailing list