diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-06-30 22:39:17 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-06-30 22:39:17 (GMT) |
commit | ce04cda63a47dd0115191d10db510438c42a60fa (patch) | |
tree | cc2a89ecf369d9d48c3e118ff13a03da00aa4105 /rhimport | |
parent | 45f396328a2fcd319b7c98ce072b32e6b22634a3 (diff) |
send curl progress message from within write function
Diffstat (limited to 'rhimport')
-rw-r--r-- | rhimport/fetcher.go | 13 |
1 files changed, 8 insertions, 5 deletions
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 } |