summaryrefslogtreecommitdiff
path: root/src/helsinki.at/rhimport/fetcher.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/helsinki.at/rhimport/fetcher.go')
-rw-r--r--src/helsinki.at/rhimport/fetcher.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/helsinki.at/rhimport/fetcher.go b/src/helsinki.at/rhimport/fetcher.go
index b4e2f0c..03cf3da 100644
--- a/src/helsinki.at/rhimport/fetcher.go
+++ b/src/helsinki.at/rhimport/fetcher.go
@@ -33,7 +33,6 @@ import (
"os"
"path"
"strings"
- "time"
)
type CurlCBData struct {
@@ -107,12 +106,11 @@ func FetchFileCurl(ctx *ImportContext, uri *url.URL) (err error) {
easy.Setopt(curl.OPT_WRITEDATA, cbdata)
easy.Setopt(curl.OPT_NOPROGRESS, false)
- started := int64(0)
easy.Setopt(curl.OPT_PROGRESSFUNCTION, func(dltotal, dlnow, ultotal, ulnow float64, userdata interface{}) bool {
- if started == 0 {
- started = time.Now().Unix()
+ ctx := userdata.(*ImportContext)
+ if ctx.ProgressCallBack != nil {
+ ctx.ProgressCallBack(1, "downloading", dlnow/dltotal, ctx.ProgressCallBackData)
}
- fmt.Printf("Downloaded: %3.2f%%, Speed: %.1fKiB/s \r", dlnow/dltotal*100, dlnow/1000/float64((time.Now().Unix()-started)))
return true
})
easy.Setopt(curl.OPT_PROGRESSDATA, ctx)
@@ -131,6 +129,9 @@ func FetchFileCurl(ctx *ImportContext, uri *url.URL) (err error) {
func FetchFileLocal(ctx *ImportContext, uri *url.URL) (err error) {
rhl.Printf("Local fetcher called for '%s'", ctx.SourceUri)
+ if ctx.ProgressCallBack != nil {
+ ctx.ProgressCallBack(1, "fetching", 1.0, ctx.ProgressCallBackData)
+ }
ctx.SourceFile = uri.Path
ctx.DeleteSourceFile = false
ctx.DeleteSourceDir = false