mirror of
https://github.com/rumanzo/bt2qbt.git
synced 2024-11-09 12:22:38 +01:00
cosmetic change for array check
This commit is contained in:
parent
f7c5d00b94
commit
e1c226eb89
13
bt2qbt.go
13
bt2qbt.go
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user