feat(actions): simplify macro parsing (#560)

* refactor(action): parse macros

* feat(action): add ctx to arr clients and test
This commit is contained in:
ze0s 2022-12-10 21:48:19 +01:00 committed by GitHub
parent f6e68fae2b
commit 839eb9f3f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 323 additions and 334 deletions

View file

@ -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)
}