Bug fix for empty labels

This commit is contained in:
akostin 2018-05-29 10:47:45 +03:00
parent 8b9baa680a
commit e64d8532b3

View File

@ -188,9 +188,9 @@ func (newstructure *NewTorrentStructure) ifcompletedon() {
newstructure.Unfinished = new([]interface{}) newstructure.Unfinished = new([]interface{})
} }
} }
func (newstructure *NewTorrentStructure) iftags(labels []interface{}) { func (newstructure *NewTorrentStructure) iftags(labels interface{}) {
if newstructure.with_tags == true && labels != nil { if newstructure.with_tags == true && labels != nil {
for _, label := range labels { for _, label := range labels.([]interface{}) {
if label != nil { if label != nil {
newstructure.Qbttags = append(newstructure.Qbttags, label.(string)) newstructure.Qbttags = append(newstructure.Qbttags, label.(string))
} }
@ -426,7 +426,7 @@ func logic(key string, value map[string]interface{}, bitdir *string, with_label
newstructure.Total_downloaded = value["downloaded"].(int64) newstructure.Total_downloaded = value["downloaded"].(int64)
newstructure.Total_uploaded = value["uploaded"].(int64) newstructure.Total_uploaded = value["uploaded"].(int64)
newstructure.Upload_rate_limit = value["upspeed"].(int64) newstructure.Upload_rate_limit = value["upspeed"].(int64)
newstructure.iftags(value["labels"].([]interface{})) newstructure.iftags(value["labels"])
if value["label"] != nil { if value["label"] != nil {
newstructure.iflabel(value["label"].(string)) newstructure.iflabel(value["label"].(string))
} else { } else {
@ -542,7 +542,8 @@ func main() {
if key != ".fileguard" && key != "rec" { if key != ".fileguard" && key != "rec" {
positionnum++ positionnum++
if with_tags == true { if with_tags == true {
for _, label := range value.(map[string]interface{})["labels"].([]interface{}) { if labels, ok := value.(map[string]interface{})["labels"]; ok {
for _, label := range labels.([]interface{}) {
if len(label.(string)) > 0 { if len(label.(string)) > 0 {
if ok, tag := checknotexists(ASCIIconvert(label.(string)), newtags); ok { if ok, tag := checknotexists(ASCIIconvert(label.(string)), newtags); ok {
newtags = append(newtags, tag) newtags = append(newtags, tag)
@ -550,6 +551,7 @@ func main() {
} }
} }
} }
}
wg.Add(1) wg.Add(1)
go logic(key, value.(map[string]interface{}), &bitdir, &with_label, &with_tags, &qbitdir, comChannel, go logic(key, value.(map[string]interface{}), &bitdir, &with_label, &with_tags, &qbitdir, comChannel,
errChannel, positionnum, &wg) errChannel, positionnum, &wg)