The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/4435

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
From 37c6c763cbdc3277a6464ef692d295b4dc1e3bf7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Tue, 10 Apr 2018 00:58:08 +0200
Subject: [PATCH] lxc/file: Fix pull target logic
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxc/file.go | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lxc/file.go b/lxc/file.go
index adde732c0f..84e59d8a44 100644
--- a/lxc/file.go
+++ b/lxc/file.go
@@ -223,7 +223,7 @@ func (c *cmdFilePull) Run(cmd *cobra.Command, args 
[]string) error {
                if !targetIsDir && len(args)-1 > 1 {
                        return fmt.Errorf(i18n.G("More than one file to 
download, but target is not a directory"))
                }
-       } else if strings.HasSuffix(target, string(os.PathSeparator)) || 
len(args)-1 > 1 || c.file.flagRecursive {
+       } else if strings.HasSuffix(args[len(args)-1], 
string(os.PathSeparator)) || len(args)-1 > 1 {
                err := os.MkdirAll(target, 0755)
                if err != nil {
                        return err
@@ -251,6 +251,14 @@ func (c *cmdFilePull) Run(cmd *cobra.Command, args 
[]string) error {
                // Deal with recursion
                if resp.Type == "directory" {
                        if c.file.flagRecursive {
+                               if !shared.PathExists(target) {
+                                       err := os.MkdirAll(target, 0755)
+                                       if err != nil {
+                                               return err
+                                       }
+                                       targetIsDir = true
+                               }
+
                                err := 
c.file.recursivePullFile(resource.server, pathSpec[0], pathSpec[1], target)
                                if err != nil {
                                        return err
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to