[lxc-devel] [lxd/master] client: Fix crash on missing ProgressTracker
stgraber on Github
lxc-bot at linuxcontainers.org
Sun Dec 9 19:56:42 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181209/ea67e36c/attachment.bin>
-------------- next part --------------
From 4df5d0ec3c15d3f3a452e6a607bee2efd0d7b725 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Sun, 9 Dec 2018 14:56:22 -0500
Subject: [PATCH] client: Fix crash on missing ProgressTracker
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
client/lxd_images.go | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/client/lxd_images.go b/client/lxd_images.go
index c4e994a7d8..bdaeaee9ef 100644
--- a/client/lxd_images.go
+++ b/client/lxd_images.go
@@ -397,14 +397,18 @@ func (r *ProtocolLXD) CreateImage(image api.ImagesPost, args *ImageCreateArgs) (
}
// Setup progress handler
- body = &ioprogress.ProgressReader{
- ReadCloser: tmpfile,
- Tracker: &ioprogress.ProgressTracker{
- Length: size,
- Handler: func(percent int64, speed int64) {
- args.ProgressHandler(ioprogress.ProgressData{Text: fmt.Sprintf("%d%% (%s/s)", percent, shared.GetByteSizeString(speed, 2))})
+ if args.ProgressHandler != nil {
+ body = &ioprogress.ProgressReader{
+ ReadCloser: tmpfile,
+ Tracker: &ioprogress.ProgressTracker{
+ Length: size,
+ Handler: func(percent int64, speed int64) {
+ args.ProgressHandler(ioprogress.ProgressData{Text: fmt.Sprintf("%d%% (%s/s)", percent, shared.GetByteSizeString(speed, 2))})
+ },
},
- },
+ }
+ } else {
+ body = tmpfile
}
contentType = w.FormDataContentType()
More information about the lxc-devel
mailing list