mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
fix(filters): handle empty tag_match_logic
by defaulting to ANY
(#910)
* speculative fix for tags_match_logic if set to ANY * add default tag match logic handling * fixed test cases and rejection messages * trim tags in match funcs * add test for empty TagsMatchLogic
This commit is contained in:
parent
537bbe3394
commit
8a1910843c
2 changed files with 34 additions and 10 deletions
|
@ -388,18 +388,18 @@ func (f Filter) CheckFilter(r *Release) ([]string, bool) {
|
|||
}
|
||||
|
||||
if f.Tags != "" {
|
||||
if f.TagsMatchLogic == "ANY" && !containsAny(r.Tags, f.Tags) {
|
||||
r.addRejectionF("tags not matching. got: %v want: %v", r.Tags, f.Tags)
|
||||
} else if f.TagsMatchLogic == "ALL" && !containsAll(r.Tags, f.Tags) {
|
||||
if f.TagsMatchLogic == "ALL" && !containsAll(r.Tags, f.Tags) {
|
||||
r.addRejectionF("tags not matching. got: %v want(all): %v", r.Tags, f.Tags)
|
||||
} else if !containsAny(r.Tags, f.Tags) { // TagsMatchLogic is set to "" by default, this makes sure that "" and "ANY" are treated the same way.
|
||||
r.addRejectionF("tags not matching. got: %v want: %v", r.Tags, f.Tags)
|
||||
}
|
||||
}
|
||||
|
||||
if f.ExceptTags != "" {
|
||||
if f.ExceptTagsMatchLogic == "ANY" && containsAny(r.Tags, f.ExceptTags) {
|
||||
r.addRejectionF("tags unwanted. got: %v want: %v", r.Tags, f.ExceptTags)
|
||||
} else if f.ExceptTagsMatchLogic == "ALL" && containsAll(r.Tags, f.ExceptTags) {
|
||||
r.addRejectionF("tags unwanted. got: %v want(all): %v", r.Tags, f.ExceptTags)
|
||||
if f.ExceptTagsMatchLogic == "ALL" && containsAll(r.Tags, f.ExceptTags) {
|
||||
r.addRejectionF("tags unwanted. got: %v don't want: %v", r.Tags, f.ExceptTags)
|
||||
} else if containsAny(r.Tags, f.ExceptTags) { // ExceptTagsMatchLogic is set to "" by default, this makes sure that "" and "ANY" are treated the same way.
|
||||
r.addRejectionF("tags unwanted. got: %v don't want: %v", r.Tags, f.ExceptTags)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -683,6 +683,7 @@ func containsMatch(tags []string, filters []string) bool {
|
|||
continue
|
||||
}
|
||||
tag = strings.ToLower(tag)
|
||||
tag = strings.Trim(tag, " ")
|
||||
|
||||
for _, filter := range filters {
|
||||
if filter == "" {
|
||||
|
@ -720,6 +721,7 @@ func containsAllMatch(tags []string, filters []string) bool {
|
|||
continue
|
||||
}
|
||||
tag = strings.ToLower(tag)
|
||||
tag = strings.Trim(tag, " ")
|
||||
|
||||
if tag == filter {
|
||||
found = true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue