summaryrefslogtreecommitdiff
path: root/src/helsinki.at/rhimport/importer.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/helsinki.at/rhimport/importer.go')
-rw-r--r--src/helsinki.at/rhimport/importer.go36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/helsinki.at/rhimport/importer.go b/src/helsinki.at/rhimport/importer.go
index 4a0bece..9af3765 100644
--- a/src/helsinki.at/rhimport/importer.go
+++ b/src/helsinki.at/rhimport/importer.go
@@ -35,7 +35,7 @@ import (
"path"
)
-func (self *ImportResult) fromRDWebResult(rdres *RDWebResult) {
+func (self *Result) fromRDWebResult(rdres *RDWebResult) {
self.ResponseCode = rdres.ResponseCode
self.ErrorString = rdres.ErrorString
if rdres.AudioConvertError != 0 {
@@ -43,7 +43,7 @@ func (self *ImportResult) fromRDWebResult(rdres *RDWebResult) {
}
}
-func addCart(ctx *ImportContext, res *ImportResult) (err error) {
+func addCart(ctx *Context, res *Result) (err error) {
rhdl.Printf("importer: addCart() called for cart: %d", ctx.Cart)
if ctx.GroupName == "" {
@@ -103,7 +103,7 @@ func addCart(ctx *ImportContext, res *ImportResult) (err error) {
return
}
-func addCut(ctx *ImportContext, res *ImportResult) (err error) {
+func addCut(ctx *Context, res *Result) (err error) {
rhdl.Printf("importer: addCut() called for cart/cut: %d/%d", ctx.Cart, ctx.Cut)
var b bytes.Buffer
w := multipart.NewWriter(&b)
@@ -150,7 +150,7 @@ func addCut(ctx *ImportContext, res *ImportResult) (err error) {
return
}
-func removeCart(ctx *ImportContext, res *ImportResult) (err error) {
+func removeCart(ctx *Context, res *Result) (err error) {
rhdl.Printf("importer: removeCart() called for cart: %d", ctx.Cart)
var b bytes.Buffer
w := multipart.NewWriter(&b)
@@ -184,7 +184,7 @@ func removeCart(ctx *ImportContext, res *ImportResult) (err error) {
return
}
-func removeCut(ctx *ImportContext, res *ImportResult) (err error) {
+func removeCut(ctx *Context, res *Result) (err error) {
rhdl.Printf("importer: removeCut() called for cart/cut: %d/%d", ctx.Cart, ctx.Cut)
var b bytes.Buffer
w := multipart.NewWriter(&b)
@@ -238,7 +238,7 @@ func sendPostRequest(url string, b *bytes.Buffer, contenttype string) (resp *htt
return
}
-func importAudioCreateRequest(ctx *ImportContext, easy *curl.CURL) (form *curl.Form, err error) {
+func importAudioCreateRequest(ctx *Context, easy *curl.CURL) (form *curl.Form, err error) {
form = curl.NewForm()
if err = form.Add("COMMAND", "2"); err != nil {
@@ -275,7 +275,7 @@ func importAudioCreateRequest(ctx *ImportContext, easy *curl.CURL) (form *curl.F
return
}
-func importAudio(ctx *ImportContext, res *ImportResult) (err error) {
+func importAudio(ctx *Context, res *Result) (err error) {
rhdl.Printf("importer: importAudio() called for cart/cut: %d/%d", ctx.Cart, ctx.Cut)
easy := curl.EasyInit()
@@ -343,24 +343,24 @@ func importAudio(ctx *ImportContext, res *ImportResult) (err error) {
return
}
-func addCartCut(ctx *ImportContext, res *ImportResult) (err error) {
+func addCartCut(ctx *Context, res *Result) (err error) {
if err = addCart(ctx, res); err != nil || res.ResponseCode != http.StatusOK {
return
}
if err = addCut(ctx, res); err != nil || res.ResponseCode != http.StatusOK {
- return removeCart(ctx, &ImportResult{ResponseCode: http.StatusOK})
+ return removeCart(ctx, &Result{ResponseCode: http.StatusOK})
}
return
}
-func removeAddCartCut(ctx *ImportContext, res *ImportResult) (err error) {
+func removeAddCartCut(ctx *Context, res *Result) (err error) {
if err = removeCart(ctx, res); err != nil || (res.ResponseCode != http.StatusOK && res.ResponseCode != http.StatusNotFound) {
return
}
return addCartCut(ctx, res)
}
-func isCartMemberOfShow(ctx *ImportContext, res *ImportResult, carts []uint) (found bool) {
+func isCartMemberOfShow(ctx *Context, res *Result, carts []uint) (found bool) {
if ctx.Cart == 0 {
return true
}
@@ -375,7 +375,7 @@ func isCartMemberOfShow(ctx *ImportContext, res *ImportResult, carts []uint) (fo
return false
}
-func clearShowCarts(ctx *ImportContext, res *ImportResult, carts []uint) (err error) {
+func clearShowCarts(ctx *Context, res *Result, carts []uint) (err error) {
if ctx.ClearShowCarts {
origCart := ctx.Cart
for _, cart := range carts {
@@ -389,14 +389,14 @@ func clearShowCarts(ctx *ImportContext, res *ImportResult, carts []uint) (err er
return
}
-func addShowCartCut(ctx *ImportContext, res *ImportResult, carts []uint) (err error) {
+func addShowCartCut(ctx *Context, res *Result, carts []uint) (err error) {
if err = addCart(ctx, res); err != nil || res.ResponseCode != http.StatusOK {
return
}
for _, cart := range carts {
if cart == ctx.Cart {
if err = addCut(ctx, res); err != nil || res.ResponseCode != http.StatusOK {
- return removeCart(ctx, &ImportResult{ResponseCode: http.StatusOK})
+ return removeCart(ctx, &Result{ResponseCode: http.StatusOK})
}
return
}
@@ -409,7 +409,7 @@ func addShowCartCut(ctx *ImportContext, res *ImportResult, carts []uint) (err er
return
}
-func cleanupFiles(ctx *ImportContext) {
+func cleanupFiles(ctx *Context) {
if ctx.DeleteSourceFile {
rhdl.Printf("importer: removing file: %s", ctx.SourceFile)
if err := os.Remove(ctx.SourceFile); err != nil {
@@ -427,7 +427,7 @@ func cleanupFiles(ctx *ImportContext) {
return
}
-func ImportFile(ctx *ImportContext) (res *ImportResult, err error) {
+func ImportFile(ctx *Context) (res *Result, err error) {
defer cleanupFiles(ctx)
rhl.Printf("importer: ImportFile called with: show-id: %d, pool-name: '%s', cart/cut: %d/%d", ctx.ShowId, ctx.GroupName, ctx.Cart, ctx.Cut)
@@ -447,7 +447,7 @@ func ImportFile(ctx *ImportContext) (res *ImportResult, err error) {
rmCartOnErr := false
rmCutOnErr := false
- res = &ImportResult{ResponseCode: http.StatusOK}
+ res = &Result{ResponseCode: http.StatusOK}
if ctx.ShowId != 0 { // Import to a show
var showCarts []uint
if showCarts, err = ctx.getShowInfo(); err != nil {
@@ -506,7 +506,7 @@ func ImportFile(ctx *ImportContext) (res *ImportResult, err error) {
rhl.Printf("Fileimport has failed (Cart/Cut %d/%d): %s", res.Cart, res.Cut, res.ErrorString)
}
// Try to clean up after failed import
- rmres := ImportResult{ResponseCode: http.StatusOK}
+ rmres := Result{ResponseCode: http.StatusOK}
if rmCartOnErr {
if rerr := removeCart(ctx, &rmres); rerr != nil {
return