Skip to content

Commit

Permalink
feat: add SetTorrentUploadLimit method
Browse files Browse the repository at this point in the history
  • Loading branch information
Jraaay committed Aug 11, 2024
1 parent b43652f commit f7d5de9
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,32 @@ func (c *Client) ToggleFirstLastPiecePrioCtx(ctx context.Context, hashes []strin
return nil
}

// SetTorrentUploadLimit set upload limit for torrent specified by hash
func (c *Client) SetTorrentUploadLimit(hash string, limit int64) error {
return c.SetTorrentUploadLimitCtx(context.Background(), hash, limit)
}

// SetTorrentUploadLimitCtx set upload limit for torrent specified by hash
func (c *Client) SetTorrentUploadLimitCtx(ctx context.Context, hash string, limit int64) error {
opts := map[string]string{
"hashes": hash,
"limit": strconv.FormatInt(limit, 10),
}

resp, err := c.postCtx(ctx, "torrents/setUploadLimit", opts)
if err != nil {
return errors.Wrap(err, "could not set upload limit torrent: %v", hash)
}

defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
return errors.New("could not set upload limit torrent: %v unexpected status: %v", hash, resp.StatusCode)
}

return nil
}

func (c *Client) GetAppVersion() (string, error) {
return c.GetAppVersionCtx(context.Background())
}
Expand Down

0 comments on commit f7d5de9

Please sign in to comment.