feat(actions): add "don't start" option for rtorrent (#782)

This commit is contained in:
metonym 2023-03-26 14:17:44 -07:00 committed by GitHub
parent 07b3569cde
commit 5fed0921c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 2 deletions

View file

@ -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) 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) return nil, errors.Wrap(err, "could not add torrent file: %s", release.TorrentTmpFile)
} }

View file

@ -402,6 +402,14 @@ const TypeForm = ({ action, idx, clients }: TypeFormProps) => {
/> />
</div> </div>
</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>
</div> </div>
); );