[lxc-devel] [lxd/master] client: fix file push

brauner on Github lxc-bot at linuxcontainers.org
Wed Apr 5 16:31:11 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 381 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170405/e320b4b5/attachment.bin>
-------------- next part --------------
From ba1ebf89e3b455f3bb178b0b974103931fa810e7 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Wed, 5 Apr 2017 18:30:18 +0200
Subject: [PATCH] client: fix file push

Closes #3153.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 client.go | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/client.go b/client.go
index 8fbdb49..a76a81f 100644
--- a/client.go
+++ b/client.go
@@ -1833,7 +1833,10 @@ func (c *Client) MkdirP(container string, p string, mode os.FileMode, uid int, g
 		return nil
 	}
 
-	parts := strings.Split(p, "/")
+	// Remove trailing "/" e.g. /A/B/C/. Otherwise we will end up with an
+	// empty array entry "" which will confuse the Mkdir() loop below.
+	pclean := filepath.Clean(p)
+	parts := strings.Split(pclean, "/")
 	i := len(parts)
 
 	for ; i >= 1; i-- {


More information about the lxc-devel mailing list