summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-06-30 22:39:17 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-06-30 22:39:17 (GMT)
commitce04cda63a47dd0115191d10db510438c42a60fa (patch)
treecc2a89ecf369d9d48c3e118ff13a03da00aa4105
parent45f396328a2fcd319b7c98ce072b32e6b22634a3 (diff)
send curl progress message from within write function
-rw-r--r--rhimport/fetcher.go13
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
}