diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-03-11 16:03:02 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-03-11 16:03:02 (GMT) |
commit | 78d356b26f82e7d1c26111d07024778ae2055e1c (patch) | |
tree | 6c8e289829139ebf00601a167434d1e49780e2d3 | |
parent | 869c36bf0d601e906ca1ca8b62449478c658a425 (diff) |
some minor refactoring
-rw-r--r-- | rhimport/fetcher.go | 6 | ||||
-rw-r--r-- | rhimport/importer.go | 13 |
2 files changed, 9 insertions, 10 deletions
diff --git a/rhimport/fetcher.go b/rhimport/fetcher.go index 9d5280b..a253eb4 100644 --- a/rhimport/fetcher.go +++ b/rhimport/fetcher.go @@ -374,14 +374,14 @@ func fetcherInit() { } } -func checkPassword(ctx *Context, result *Result) (err error) { +func checkPassword(ctx *Context, res *Result) (err error) { ok := false if ok, err = ctx.CheckPassword(); err != nil { return } if !ok { - result.ResponseCode = http.StatusUnauthorized - result.ErrorString = "invalid username and/or password" + res.ResponseCode = http.StatusUnauthorized + res.ErrorString = "invalid username and/or password" } return } diff --git a/rhimport/importer.go b/rhimport/importer.go index 8e58ff6..6d994c3 100644 --- a/rhimport/importer.go +++ b/rhimport/importer.go @@ -36,11 +36,11 @@ import ( "github.com/andelf/go-curl" ) -func (self *Result) fromRDWebResult(rdres *RDWebResult) { - self.ResponseCode = rdres.ResponseCode - self.ErrorString = rdres.ErrorString +func (res *Result) fromRDWebResult(rdres *RDWebResult) { + res.ResponseCode = rdres.ResponseCode + res.ErrorString = rdres.ErrorString if rdres.AudioConvertError != 0 { - self.ErrorString += fmt.Sprintf(", Audio Convert Error: %d", rdres.AudioConvertError) + res.ErrorString += fmt.Sprintf(", Audio Convert Error: %d", rdres.AudioConvertError) } } @@ -507,13 +507,12 @@ func ImportFile(ctx *Context) (res *Result, 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 := Result{ResponseCode: http.StatusOK} if rmCartOnErr { - if rerr := removeCart(ctx, &rmres); rerr != nil { + if rerr := removeCart(ctx, &Result{ResponseCode: http.StatusOK}); rerr != nil { return } } else if rmCutOnErr { - if rerr := removeCut(ctx, &rmres); rerr != nil { + if rerr := removeCut(ctx, &Result{ResponseCode: http.StatusOK}); rerr != nil { return } } |