fix(macros): torrentdata parsing (#757)

* fix(macros): Fix torrentdata parsing in macros.

* fix action test

* more dead code

* hunting demons

* limit success output
This commit is contained in:
Kyle Sanderson 2023-03-19 12:53:42 -07:00 committed by GitHub
parent 92f2b0ebe3
commit 29bedc532d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 54 additions and 83 deletions

View file

@ -2,9 +2,7 @@ package action
import (
"context"
"os"
"os/exec"
"strings"
"time"
"github.com/autobrr/autobrr/internal/domain"
@ -16,22 +14,6 @@ import (
func (s *service) execCmd(ctx context.Context, action *domain.Action, release domain.Release) error {
s.log.Debug().Msgf("action exec: %s release: %s", action.Name, release.TorrentName)
if release.TorrentTmpFile == "" && strings.Contains(action.ExecArgs, "TorrentPathName") {
if err := release.DownloadTorrentFileCtx(ctx); err != nil {
return errors.Wrap(err, "error downloading torrent file for release: %s", release.TorrentName)
}
}
// read the file into bytes we can then use in the macro
if len(release.TorrentDataRawBytes) == 0 && release.TorrentTmpFile != "" {
t, err := os.ReadFile(release.TorrentTmpFile)
if err != nil {
return errors.Wrap(err, "could not read torrent file: %s", release.TorrentTmpFile)
}
release.TorrentDataRawBytes = t
}
// check if program exists
cmd, err := exec.LookPath(action.ExecCmd)
if err != nil {