[lxc-devel] [lxd/master] Proper fix for #2403 - create target dir on recursive pull
techtonik on Github
lxc-bot at linuxcontainers.org
Wed Sep 21 16:21:55 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 355 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160921/dbdab5c8/attachment.bin>
-------------- next part --------------
From 9fd7f39ab849b74d94b0e3019ae32c35d66afb50 Mon Sep 17 00:00:00 2001
From: anatoly techtonik <techtonik at 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 <techtonik at 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
}
More information about the lxc-devel
mailing list