cosmetic change for array check

This commit is contained in:
rumanzo 2021-05-07 17:41:53 +03:00
parent f7c5d00b94
commit e1c226eb89

View File

@ -73,13 +73,14 @@ func ASCIIconvert(s string) string {
return buffer.String()
}
func checknotexists(s string, tags []string) (bool, string) {
for _, value := range tags {
// return true and string if string exists in array, else false and string
func checkexists(s string, arr []string) (bool, string) {
for _, value := range arr {
if value == s {
return false, s
return true, s
}
}
return true, s
return false, s
}
func decodetorrentfile(path string) (map[string]interface{}, error) {
@ -387,7 +388,7 @@ func transfertorrents(chans Channels, flags Flags, resumefile map[string]interfa
if labels, ok := value.(map[string]interface{})["labels"]; ok {
for _, label := range labels.([]interface{}) {
if len(label.(string)) > 0 {
if ok, tag := checknotexists(ASCIIconvert(label.(string)), newtags); ok {
if exists, tag := checkexists(ASCIIconvert(label.(string)), newtags); !exists {
newtags = append(newtags, tag)
}
}
@ -440,7 +441,7 @@ func transfertorrents(chans Channels, flags Flags, resumefile map[string]interfa
if cfg.Section("BitTorrent").HasKey("Session\\Tags") {
oldtags = cfg.Section("BitTorrent").Key("Session\\Tags").String()
for _, tag := range strings.Split(oldtags, ", ") {
if ok, t := checknotexists(tag, newtags); ok {
if exists, t := checkexists(tag, newtags); !exists {
newtags = append(newtags, t)
}
}