fix(actions): trim tags categories and save path for qbittorrent (#916)

trim tags, categories and save path for qbit
This commit is contained in:
soup 2023-05-06 23:40:22 +02:00 committed by GitHub
parent 1abc260047
commit cf61bcf672
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,6 +6,7 @@ package action
import ( import (
"context" "context"
"fmt" "fmt"
"strings"
"github.com/autobrr/autobrr/internal/domain" "github.com/autobrr/autobrr/internal/domain"
"github.com/autobrr/autobrr/pkg/errors" "github.com/autobrr/autobrr/pkg/errors"
@ -96,14 +97,27 @@ func (s *service) prepareQbitOptions(action *domain.Action) (map[string]string,
// if ORIGINAL then leave empty // if ORIGINAL then leave empty
} }
if action.SavePath != "" { if action.SavePath != "" {
opts.SavePath = action.SavePath opts.SavePath = strings.TrimSpace(action.SavePath)
opts.AutoTMM = false opts.AutoTMM = false
} }
if action.Category != "" { if action.Category != "" {
opts.Category = action.Category opts.Category = strings.TrimSpace(action.Category)
} }
if action.Tags != "" { if action.Tags != "" {
opts.Tags = action.Tags // Split the action.Tags string by comma
tags := strings.Split(action.Tags, ",")
// Create a new slice to store the trimmed tags
trimmedTags := make([]string, 0, len(tags))
// Iterate over the tags and trim each one
for _, tag := range tags {
trimmedTag := strings.TrimSpace(tag)
trimmedTags = append(trimmedTags, trimmedTag)
}
// Join the trimmed tags back together with commas
opts.Tags = strings.Join(trimmedTags, ",")
} }
if action.LimitUploadSpeed > 0 { if action.LimitUploadSpeed > 0 {
opts.LimitUploadSpeed = action.LimitUploadSpeed opts.LimitUploadSpeed = action.LimitUploadSpeed