From 5fed0921c5607966b09224bf9baf52bfad871c32 Mon Sep 17 00:00:00 2001 From: metonym <127705169+metonyms@users.noreply.github.com> Date: Sun, 26 Mar 2023 14:17:44 -0700 Subject: [PATCH] feat(actions): add "don't start" option for rtorrent (#782) --- internal/action/rtorrent.go | 18 ++++++++++++++++-- web/src/screens/filters/action.tsx | 8 ++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/internal/action/rtorrent.go b/internal/action/rtorrent.go index 87caf10..459616e 100644 --- a/internal/action/rtorrent.go +++ b/internal/action/rtorrent.go @@ -54,7 +54,14 @@ func (s *service) rtorrent(ctx context.Context, action *domain.Action, release d } } - if err := rt.Add(release.MagnetURI, args...); err != nil { + var addTorrentMagnet func(string, ...*rtorrent.FieldValue) error + if action.Paused { + addTorrentMagnet = rt.AddStopped + } else { + addTorrentMagnet = rt.Add + } + + if err := addTorrentMagnet(release.MagnetURI, args...); err != nil { return nil, errors.Wrap(err, "could not add torrent from magnet: %s", release.MagnetURI) } @@ -97,7 +104,14 @@ func (s *service) rtorrent(ctx context.Context, action *domain.Action, release d } } - if err := rt.AddTorrent(tmpFile, args...); err != nil { + var addTorrentFile func([]byte, ...*rtorrent.FieldValue) error + if action.Paused { + addTorrentFile = rt.AddTorrentStopped + } else { + addTorrentFile = rt.AddTorrent + } + + if err := addTorrentFile(tmpFile, args...); err != nil { return nil, errors.Wrap(err, "could not add torrent file: %s", release.TorrentTmpFile) } diff --git a/web/src/screens/filters/action.tsx b/web/src/screens/filters/action.tsx index fc0d46f..6265d51 100644 --- a/web/src/screens/filters/action.tsx +++ b/web/src/screens/filters/action.tsx @@ -402,6 +402,14 @@ const TypeForm = ({ action, idx, clients }: TypeFormProps) => { /> +
+
+ +
+
);