diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-07-15 15:56:01 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-07-15 15:56:01 (GMT) |
commit | 49a33ef6dcfccda67c9afc54d4dc061a74dfbb6d (patch) | |
tree | 96157f947c171d17cae04550c7a038b31d62a03a /rhimport/core.go | |
parent | f4801e4f33eb9683dacefdac0687eaa217b01213 (diff) |
progress messages now contain file title
Diffstat (limited to 'rhimport/core.go')
-rw-r--r-- | rhimport/core.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/rhimport/core.go b/rhimport/core.go index cf51c54..fc92f6a 100644 --- a/rhimport/core.go +++ b/rhimport/core.go @@ -29,6 +29,7 @@ import ( "io/ioutil" "log" "os" + "path" "code.helsinki.at/rhrd-go/rddb" "github.com/andelf/go-curl" @@ -60,7 +61,7 @@ func init() { fetcherInit() } -type ProgressCB func(step int, stepName string, current, total float64, cart, cut uint, userdata interface{}) bool +type ProgressCB func(step int, stepName string, current, total float64, title string, cart, cut uint, userdata interface{}) bool type DoneCB func(result Result, userdata interface{}) bool type Result struct { @@ -130,6 +131,7 @@ type Context struct { AttachmentChan <-chan []byte FetchConverter string OrigFilename string + Title string SourceFile string DeleteSourceFile bool DeleteSourceDir bool @@ -160,6 +162,7 @@ func NewContext(conf *Config, db *rddb.DBChan) *Context { ctx.AttachmentChan = nil ctx.FetchConverter = "ffmpeg-bs1770" ctx.OrigFilename = "" + ctx.Title = "" ctx.SourceFile = "" ctx.DeleteSourceFile = false ctx.DeleteSourceDir = false @@ -259,7 +262,14 @@ func (ctx *Context) updateCutCartTitle() (err error) { func (ctx *Context) reportProgress(step int, stepName string, current, total float64) { if ctx.ProgressCallBack != nil { - if keep := ctx.ProgressCallBack(step, stepName, current, total, ctx.Cart, ctx.Cut, ctx.ProgressCallBackData); !keep { + title := ctx.Title + if title == "" { + title = path.Base(ctx.OrigFilename) + if title == "" { + title = path.Base(ctx.SourceFile) + } + } + if keep := ctx.ProgressCallBack(step, stepName, current, total, title, ctx.Cart, ctx.Cut, ctx.ProgressCallBackData); !keep { ctx.ProgressCallBack = nil } } |