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

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: anatoly techtonik <techto...@gmail.com>
From 9fd7f39ab849b74d94b0e3019ae32c35d66afb50 Mon Sep 17 00:00:00 2001
From: anatoly techtonik <techto...@gmail.com>
Date: Wed, 21 Sep 2016 18:57:59 +0300
Subject: [PATCH] Proper fix for #2403 - create target dir on recursive pull

Signed-off-by: anatoly techtonik <techto...@gmail.com>
---
 lxc/file.go | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/lxc/file.go b/lxc/file.go
index d143a20..19626cb 100644
--- a/lxc/file.go
+++ b/lxc/file.go
@@ -215,17 +215,18 @@ func (c *fileCmd) pull(config *lxd.Config, args []string) 
error {
 
        /*
         * If the path exists, just use it. If it doesn't exist, it might be a
-        * directory in one of two cases:
+        * directory in one of three cases:
         *   1. Someone explicitly put "/" at the end
         *   2. Someone provided more than one source. In this case the target
         *      should be a directory so we can save all the files into it.
+        *   3. We are dealing with recursive copy
         */
        if err == nil {
                targetIsDir = sb.IsDir()
                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 {
+       } else if strings.HasSuffix(target, string(os.PathSeparator)) || 
len(args)-1 > 1 || c.recursive {
                if err := os.MkdirAll(target, 0755); err != nil {
                        return err
                }
@@ -245,10 +246,6 @@ func (c *fileCmd) pull(config *lxd.Config, args []string) 
error {
                }
 
                if c.recursive {
-                       if err := os.MkdirAll(target, 0755); err != nil && 
!os.IsExist(err) {
-                               return err
-                       }
-
                        if err := d.RecursivePullFile(container, pathSpec[1], 
target); err != nil {
                                return err
                        }
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to