Skip to content

Commit

Permalink
feat(actions): add "don't start" option for rtorrent (#782)
Browse files Browse the repository at this point in the history
  • Loading branch information
metonyms committed Mar 26, 2023
1 parent 07b3569 commit 5fed092
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
18 changes: 16 additions & 2 deletions internal/action/rtorrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand Down
8 changes: 8 additions & 0 deletions web/src/screens/filters/action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,14 @@ const TypeForm = ({ action, idx, clients }: TypeFormProps) => {
/>
</div>
</div>
<div className="col-span-12 sm:col-span-6">
<div className="col-span-6">
<SwitchGroup
name={`actions.${idx}.paused`}
label="Don't start download automatically"
/>
</div>
</div>
</div>
</div>
);
Expand Down

0 comments on commit 5fed092

Please sign in to comment.