summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2015-12-19 02:55:57 (GMT)
committerChristian Pointner <equinox@helsinki.at>2015-12-19 02:55:57 (GMT)
commit1f3dab1eab175c4c0e4d4d6d3c339daf02899ca9 (patch)
treeb5862f40f116a7459cef074ae6a05c94a7863462 /src
parentd4e8c888f9148d1e5ac39ef4cb6aa9203437d1db (diff)
improved show based imports
Diffstat (limited to 'src')
-rw-r--r--src/helsinki.at/rhimport/importer.go11
-rw-r--r--src/helsinki.at/rhimportd/ctrlTelnet.go31
2 files changed, 29 insertions, 13 deletions
diff --git a/src/helsinki.at/rhimport/importer.go b/src/helsinki.at/rhimport/importer.go
index 94065f6..afe422f 100644
--- a/src/helsinki.at/rhimport/importer.go
+++ b/src/helsinki.at/rhimport/importer.go
@@ -525,6 +525,7 @@ func is_cart_member_of_show(ctx *ImportContext, res *ImportResult, carts []uint)
}
res.ResponseCode = http.StatusBadRequest
res.ErrorString = fmt.Sprintf("Requested cart %d is not a member of show: %d", ctx.Cart, ctx.ShowId)
+ res.Cart = ctx.Cart
return false
}
@@ -609,8 +610,14 @@ func ImportFile(ctx *ImportContext) (res *ImportResult, err error) {
if err = clear_show_carts(ctx, res, show_carts); err != nil || (res.ResponseCode != http.StatusOK && res.ResponseCode != http.StatusNotFound) {
return
}
- if err = add_show_cart_cut(ctx, res, show_carts); err != nil || res.ResponseCode != http.StatusOK {
- return
+ if ctx.ClearCart && !ctx.ClearShowCarts {
+ if err = remove_add_cart_cut(ctx, res); err != nil || res.ResponseCode != http.StatusOK {
+ return
+ }
+ } else {
+ if err = add_show_cart_cut(ctx, res, show_carts); err != nil || res.ResponseCode != http.StatusOK {
+ return
+ }
}
rmCartOnErr = true
} else if ctx.GroupName != "" {
diff --git a/src/helsinki.at/rhimportd/ctrlTelnet.go b/src/helsinki.at/rhimportd/ctrlTelnet.go
index a329f59..b73d8db 100644
--- a/src/helsinki.at/rhimportd/ctrlTelnet.go
+++ b/src/helsinki.at/rhimportd/ctrlTelnet.go
@@ -92,15 +92,20 @@ func (c *TelnetClient) handle_cmd_help(args []string) {
c.say(" UserName, Password and SourceUri are mandatory parameters.")
c.say("")
c.say(" If ShowId is supplied GroupName, Channels, NomalizationLevel, AutorimLevel, UseMetaData")
- c.say(" and Cut will be ignored. The values from the shows dropbox will be used instead. Cart may")
- c.say(" be specified but must point to a empty cart within that show. If Cart is 0 the next free")
- c.say(" cart in the show will be used. Show carts will always be imported into cut 1.")
+ c.say(" and Cut will be ignored. The values from the shows' dropbox will be used instead. Cart may")
+ c.say(" be specified but must point to an empty cart within that show. If ClearCut is true the")
+ c.say(" specified cart will get deleted before importing. If Cart is 0 the next free cart in the")
+ c.say(" show will be used. Show carts will always be imported into cut 1.")
c.say("")
c.say(" If GroupName is supplied Channels, NomalizationLevel, AutorimLevel, UseMetaData, Cut and")
- c.say(" Cart will be ignored. The values from the music pools dropbox will be used instead. The ")
+ c.say(" Cart will be ignored. The values from the music pools' dropbox will be used instead. The")
c.say(" file will always be imported into cut 1 of the first free cart within the music pool.")
c.say("")
- c.say(" If Cut is omitted the file will imported into the next free cut within the cart.")
+ c.say(" If ShowId and GroupName are omitted a Cart must be specified. Cut may be supplied in which")
+ c.say(" case both cart and cut must already exist. The import will then replace the contents of the")
+ c.say(" current data stored in Cart/Cut. If only Cart and no Cut is supplied and ClearCut is false the")
+ c.say(" file will either get imported into the next cut of an existing cart or the cart will be created")
+ c.say(" and the file will be imported into cut 1 of this cart.")
c.say("")
c.say(" In case of an error carts/cuts which might got created will be removed. Carts which got")
c.say(" deleted because of ClearShowCarts or ClearCart are however gone for good.")
@@ -138,6 +143,7 @@ func (c *TelnetClient) handle_cmd_set(args []string) {
}
if c.ctx == nil {
c.ctx = rhimport.NewImportContext(c.conf, c.rddb, "")
+ c.ctx.Trusted = true // TODO: set this back to false as soon as debugging is done
}
switch strings.ToLower(args[0]) {
case "username":
@@ -244,27 +250,30 @@ func (c *TelnetClient) handle_cmd_run(args []string) {
c.say("context is empty please set at least one option")
return
}
+ ctx := *c.ctx
- if err := c.ctx.SanityCheck(); err != nil {
+ if err := ctx.SanityCheck(); err != nil {
c.say("sanity check for import context returned: %s", err)
return
}
- c.say("fetching file from '%s'", c.ctx.SourceUri)
- if err := rhimport.FetchFile(c.ctx); err != nil {
+ c.say("fetching file from '%s'", ctx.SourceUri)
+ if err := rhimport.FetchFile(&ctx); err != nil {
c.say("fetch file error: %s", err)
return
}
- c.say("importing file '%s'", c.ctx.SourceFile)
- if result, err := rhimport.ImportFile(c.ctx); err != nil {
+ c.say("importing file '%s'", ctx.SourceFile)
+ if result, err := rhimport.ImportFile(&ctx); err != nil {
c.say("import file error: %s", err)
return
} else {
if result.ResponseCode == http.StatusOK {
c.say("File got succesfully imported into Cart/Cut %d/%d", result.Cart, result.Cut)
+ rhl.Printf("File got succesfully imported into Cart/Cut %d/%d", result.Cart, result.Cut)
} else {
- c.say("Fileimport has failed (Cart/Cut %d/%d)", result.Cart, result.Cut)
+ c.say("Fileimport has failed (Cart/Cut %d/%d): %s", result.Cart, result.Cut, result.ErrorString)
+ rhl.Printf("Fileimport has failed (Cart/Cut %d/%d): %s", result.Cart, result.Cut, result.ErrorString)
}
}
}