summaryrefslogtreecommitdiff
path: root/importer.go
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2015-12-21 21:19:27 (GMT)
committerChristian Pointner <equinox@helsinki.at>2015-12-21 21:19:27 (GMT)
commitfa4e8087ca710222069e0353bd591056f03f98b2 (patch)
treeb6098a8d34b4237a7dc4154ee4b4815f6d6e1ab9 /importer.go
parenta51ab35bc71f678fcc0bc07bd2d2fd682587381e (diff)
canceling using works now
Diffstat (limited to 'importer.go')
-rw-r--r--importer.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/importer.go b/importer.go
index df491d7..512daf6 100644
--- a/importer.go
+++ b/importer.go
@@ -502,10 +502,11 @@ func import_audio(ctx *ImportContext, res *ImportResult) (err error) {
easy.Setopt(curl.OPT_NOPROGRESS, false)
easy.Setopt(curl.OPT_PROGRESSFUNCTION, func(dltotal, dlnow, ultotal, ulnow float64, userdata interface{}) bool {
if ctx.Cancel != nil && len(ctx.Cancel) > 0 {
+ res.ResponseCode = http.StatusNoContent
+ res.ErrorString = "canceled"
return false
}
- ctx := userdata.(*ImportContext)
if ctx.ProgressCallBack != nil {
ctx.ProgressCallBack(2, "importing", ulnow/ultotal, ctx.ProgressCallBackData)
}
@@ -514,7 +515,13 @@ func import_audio(ctx *ImportContext, res *ImportResult) (err error) {
easy.Setopt(curl.OPT_PROGRESSDATA, ctx)
if err = easy.Perform(); err != nil {
- err = fmt.Errorf("importer: %s", err)
+ if res.ResponseCode == http.StatusNoContent {
+ res.Cart = ctx.Cart
+ res.Cut = ctx.Cut
+ err = nil
+ } else {
+ err = fmt.Errorf("importer: %s", err)
+ }
return
}