Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BREAKING CHANGE] Implement group, sequentialDownload for torrent-set #94

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

lv10wizard
Copy link

This PR implements group and sequentialDownload on TorrentSetArgs and should fully resolve #81 with the changes from #92.

Breaking Change

Along with the breaking changes from #92 (from which these changes are based -- sorry if I'm supposed to base off of main), it also contains the following breaking changes:

  • Makes TorrentSetArgs's ids field private. It is blindly overwritten in RpcRequest::torrent_set. Exposing it to users only invites confusion (or worse: a hidden, hard to track-down bug) since any value they set will be unused.

  • (click to expand) Changes the types of various TorrentSetArgs fields to mirror transmission.h
    • download_limit: i32 -> usize
    • files_wanted: Vec<i32> -> <usize>
    • files_unwanted: Vec<i32> -> <usize>
    • peer_limit: i64 -> u16
    • priority_high: Vec<i32> -> <usize>
    • priority_low: Vec<i32> -> <usize>
    • priority_normal: Vec<i32> -> <usize>
    • queue_position: i32 -> usize
    • seed_idle_limit: i32 -> u16 (transmission.h defines void tr_torrentSetIdleLimit(tr_torrent* tor, uint16_t idle_minutes);)
    • seed_idle_mode: i32 -> IdleMode enum
    • seed_ratio_limit: f32 -> f64 (transmission.h defines void tr_torrentSetRatioLimit(tr_torrent* tor, double desired_ratio);)
    • seed_ratio_mode: i32 -> RatioMode enum
    • upload_limit: i32 -> usize

Also in this PR

  • Added fluent setters on TorrentSetArgs as an alternate way to construct it, eg:
let args = TorrentSetArgs::default()
                .group("my-bandwidth-group")
                .labels(vec!["label", "another-label"])
                .location("/my/downloads/")
                .sequential_download(true);

lv10wizard added 12 commits September 15, 2024 12:06
BREAKING CHANGE: The existing Torrent `_date` fields are now parsed into
`DateTime<Utc>` from `i64`. Invalid or missing `_date` fields are parsed
into `DateTime::UNIX_EPOCH`.

The affected `Torrent` fields are:
    * activity_date
    * added_date
    * done_date
    * edit_date

-----

This commit implements the remaining `torrent-get` fields through
transmission version `4.1.0` (rpc-version-semver: `5.4.0`, rpc-version:
`18`). Unless I missed something, the only missing fields should now be
`files.beginPiece` and `files.endPiece`.

* The `pieces` implementation adds a dependency on `base64`
  (https://docs.rs/base64/).

* Exposes `IdleMode` and `RatioMode` enums which are the same but are
  defined as separate enums in transmission itself
  (libtransmission/transmission.h: `tr_idlelimit` and `tr_ratiolimit`).
  I've opted to mirror that here instead of combining them.

* The unit tests are effectively tests against transmission rpc response
  deserialization. Notably, they do not test against a malformed
  response.

* The unit tests for `availability` and `trackerList` are `#[ignore]`d
  because I don't have a way to get valid test data for them.
It's possible the type needs to be larger (i32 or maybe i64 even).
BREAKING CHANGE: Torrent.wanted type change from `Vec<i8>` to `Wanted`
which is a simple wrapper around `Vec<bool>`. The `Wanted` type, like
`Pieces` implements `Deref` resolving to `&Vec<_>`.

* Adds a dependency on `serde_json` (which was solely a dev-dependency
  prior to this commit).
Users probably won't need to use or reference these types explicitly but
exporting them makes the documentation link to their definitions which
can be useful.
Adds `begin_piece` and `end_piece` to the Torrent files' subtype `File`.
They are wrapped in `Option` because the fields are not present in
transmission versions less than `4.1.0`.

This should bring `torrent-get` up to the currently defined rpc spec
(transmission 4.1.0, rpc-version: 18).
This splits out the types that users probably won't need to explicitly
interact with into a separate export block 1) for documentation and 2)
as a visual distinction.
* Adds feature flag documentation
@red-avtovo
Copy link
Member

Much appreciated for the change request.
Will review that right after the #92. But from the CI run I see that format checker is not happy

@red-avtovo
Copy link
Member

Also I believe this PR should be based on top of the previous one. So rebase would be needed once the other one is merged

lv10wizard added 6 commits October 12, 2024 11:32
This offers an alternate way to construct TorrentSetArgs:

```
let args = TorrentSetArgs::default()
                .location("/foo/bar/baz")
                .labels(vec!["foo"]);
```

vs. (or similar)

```
let mut args = TorrentSetArgs::default();
args.location = Some("/foo/bar/baz");
args.location = Some(vec!["foo"]);
```
BREAKING CHANGE: Changes the types of various fields in TorrentSetArgs
to mirror the types defined in [1] `transmission.h` (as of Aug 12, 2024:
[2] dbea328).

* Refactors IdleMode, RatioMode from response.rs -> request.rs
* Fixes TorrentSetArgs setter extraneous allocations

[1] https://github.com/transmission/transmission/blob/dbea32809ae7b75d52d236ebe1e6a4739d453349/libtransmission/transmission.h
[2] transmission/transmission@dbea328
BREAKING CHANGE: This is a breaking change if users were referencing
this field directly.

This field is blindly overwritten by `RpcRequest::torrent_set` so it
should not be exposed to users.

Possibly a better solution would be to leave it exposed (so not a
breaking change) and _somehow_ merge TorrentSetArgs.ids with the `ids`
passed into `RpcRequest::torrent_set`, maybe something like:

    - `torrent_set(..., None)` overrides any TorrentSetArgs.ids
    - any ids defined in TorrentSetArgs are included into ids that are
      passed to `RpcRequest::torrent_set`.

... though, this could have unintended side effects somewhere.
* Removes the "(some)" distinction for "torrent-set" as the changes to
  TorrentSetArgs should bring the library up to date with the
  torrent-set definition.

* Removes extraneous "Id" import

* cargo fmt --all
@lv10wizard
Copy link
Author

Rebased. This should now fast-forward from #92.

(I thought I did this initially but I guess I messed up somewhere)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add sequentialDownload from 4.1.0
2 participants