mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
feat(actions): simplify macro parsing (#560)
* refactor(action): parse macros * feat(action): add ctx to arr clients and test
This commit is contained in:
parent
f6e68fae2b
commit
839eb9f3f3
31 changed files with 323 additions and 334 deletions
|
@ -9,13 +9,13 @@ import (
|
|||
"github.com/hekmon/transmissionrpc/v2"
|
||||
)
|
||||
|
||||
func (s *service) transmission(action domain.Action, release domain.Release) ([]string, error) {
|
||||
func (s *service) transmission(ctx context.Context, action *domain.Action, release domain.Release) ([]string, error) {
|
||||
s.log.Debug().Msgf("action Transmission: %v", action.Name)
|
||||
|
||||
var err error
|
||||
|
||||
// get client for action
|
||||
client, err := s.clientSvc.FindByID(context.TODO(), action.ClientID)
|
||||
client, err := s.clientSvc.FindByID(ctx, action.ClientID)
|
||||
if err != nil {
|
||||
s.log.Error().Stack().Err(err).Msgf("error finding client: %v", action.ClientID)
|
||||
return nil, err
|
||||
|
@ -28,7 +28,7 @@ func (s *service) transmission(action domain.Action, release domain.Release) ([]
|
|||
var rejections []string
|
||||
|
||||
if release.TorrentTmpFile == "" {
|
||||
if err := release.DownloadTorrentFile(); err != nil {
|
||||
if err := release.DownloadTorrentFileCtx(ctx); err != nil {
|
||||
s.log.Error().Err(err).Msgf("could not download torrent file for release: %v", release.TorrentName)
|
||||
return nil, err
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ func (s *service) transmission(action domain.Action, release domain.Release) ([]
|
|||
}
|
||||
|
||||
// Prepare and send payload
|
||||
torrent, err := tbt.TorrentAdd(context.TODO(), payload)
|
||||
torrent, err := tbt.TorrentAdd(ctx, payload)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not add torrent %v to client: %v", release.TorrentTmpFile, client.Host)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue