88 lines
3.4 KiB
Diff
88 lines
3.4 KiB
Diff
From 94370570af71e033c8984652a80f7ac20572c8a4 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber@ubuntu.com>
|
|
Date: Tue, 3 Apr 2018 10:29:53 -0400
|
|
Subject: 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@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 d441af23..b8f0f4ed 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 26f238de..b5bf5bb7 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/.
|