summaryrefslogtreecommitdiff
path: root/rhimport/importer.go
diff options
context:
space:
mode:
Diffstat (limited to 'rhimport/importer.go')
-rw-r--r--rhimport/importer.go34
1 files changed, 5 insertions, 29 deletions
diff --git a/rhimport/importer.go b/rhimport/importer.go
index 57c525d..69422e2 100644
--- a/rhimport/importer.go
+++ b/rhimport/importer.go
@@ -30,9 +30,6 @@ import (
"fmt"
"mime/multipart"
"net/http"
- "os"
- "path"
- "strings"
"github.com/andelf/go-curl"
)
@@ -402,31 +399,10 @@ func addShowCartCut(ctx *Context, res *Result, carts []uint) (err error) {
return
}
-func cleanupFiles(ctx *Context, res *Result) {
- if ctx.DeleteSourceFile {
- ctx.dbglog.Printf("importer: removing file: %s", ctx.SourceFile)
- if err := os.Remove(ctx.SourceFile); err != nil {
- ctx.stdlog.Printf("importer: error removing source file: %s", err)
- return
- }
- if ctx.DeleteSourceDir {
- dir := path.Dir(ctx.SourceFile)
- ctx.dbglog.Printf("importer: also removing directory: %s", dir)
- if err := os.Remove(dir); err != nil {
- ctx.stdlog.Printf("importer: error removing source directory: %s", err)
- }
- }
- } else {
- res.SourceFile = "tmp://" + strings.TrimPrefix(ctx.SourceFile, ctx.conf.TempDir)
- }
- return
-}
-
func ImportFile(ctx *Context) (res *Result, err error) {
res = &Result{ResponseCode: http.StatusOK}
- defer cleanupFiles(ctx, res)
- ctx.stdlog.Printf("importer: ImportFile called with: show-id: %d, pool-name: '%s', cart/cut: %d/%d", ctx.ShowId, ctx.GroupName, ctx.Cart, ctx.Cut)
+ ctx.stdlog.Printf("ImportFile: called with: show-id: %d, pool-name: '%s', cart/cut: %d/%d", ctx.ShowId, ctx.GroupName, ctx.Cart, ctx.Cut)
// TODO: on trusted interfaces we should call getPassword again with cached=false after 401's
if ctx.Trusted {
@@ -480,9 +456,9 @@ func ImportFile(ctx *Context) (res *Result, err error) {
if ctx.Cart != 0 && ctx.Cut != 0 { // Import to specific Cut within Cart
if err = importAudio(ctx, res); err != nil || res.ResponseCode != http.StatusOK {
if err != nil {
- ctx.stdlog.Printf("Fileimport has failed (Cart/Cut %d/%d): %s", ctx.Cart, ctx.Cut, err)
+ ctx.stdlog.Printf("ImportFile: import failed (Cart/Cut %d/%d): %s", ctx.Cart, ctx.Cut, err)
} else {
- ctx.stdlog.Printf("Fileimport has failed (Cart/Cut %d/%d): %s", res.Cart, res.Cut, res.ErrorString)
+ ctx.stdlog.Printf("ImportFile: import failed (Cart/Cut %d/%d): %s", res.Cart, res.Cut, res.ErrorString)
}
// Try to clean up after failed import
if rmCartOnErr {
@@ -498,11 +474,11 @@ func ImportFile(ctx *Context) (res *Result, err error) {
if err := ctx.updateCutCartTitle(); err != nil {
ctx.stdlog.Printf("Warning: error while updating Cart/Cut Title: %v", err)
}
- ctx.stdlog.Printf("File got succesfully imported into Cart/Cut %d/%d", res.Cart, res.Cut)
+ ctx.stdlog.Printf("ImportFile: succesfully imported into Cart/Cut %d/%d", res.Cart, res.Cut)
}
} else {
res.ResponseCode = http.StatusBadRequest
- res.ErrorString = "importer: The request doesn't contain enough information to be processed"
+ res.ErrorString = "ImportFile: The request doesn't contain enough information to be processed"
}
return