From ce04cda63a47dd0115191d10db510438c42a60fa Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 1 Jul 2016 00:39:17 +0200 Subject: send curl progress message from within write function diff --git a/rhimport/fetcher.go b/rhimport/fetcher.go index 45d2e7b..1cc6439 100644 --- a/rhimport/fetcher.go +++ b/rhimport/fetcher.go @@ -49,6 +49,7 @@ type FetcherCurlCBData struct { filename string remotename string conv FetchConverter + totalSize float64 written uint64 writeError error } @@ -99,6 +100,12 @@ func curlWriteCallback(ptr []byte, userdata interface{}) bool { return false } + if data.ctx.ProgressCallBack != nil { + if keep := data.ctx.ProgressCallBack(1, "downloading", float64(data.written), data.totalSize, data.ctx.ProgressCallBackData); !keep { + data.ctx.ProgressCallBack = nil + } + } + return true } @@ -121,11 +128,7 @@ func curlProgressCallback(dltotal, dlnow, ultotal, ulnow float64, userdata inter return false } - if data.ctx.ProgressCallBack != nil { - if keep := data.ctx.ProgressCallBack(1, "downloading", dlnow, dltotal, data.ctx.ProgressCallBackData); !keep { - data.ctx.ProgressCallBack = nil - } - } + data.totalSize = dltotal return true } -- cgit v0.10.2