From 9c436d87ddac1f4e15797feeb84c5eb9474a4ae6 Mon Sep 17 00:00:00 2001 From: reardonia <2925104+reardonia@users.noreply.github.com> Date: Tue, 7 Mar 2023 20:44:25 -0500 Subject: [PATCH] fix: torrentGet.wanted RPC breaking change in [4.0.0..4.0.1] (#5170) --- docs/rpc-spec.md | 4 ++-- libtransmission/rpcimpl.cc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/rpc-spec.md b/docs/rpc-spec.md index 85e6adb18..12ee5c509 100644 --- a/docs/rpc-spec.md +++ b/docs/rpc-spec.md @@ -299,7 +299,7 @@ The 'source' column here corresponds to the data structure there. | Key | Value Type | transmission.h source |:--|:--|:-- | `bytesCompleted` | number | tr_file_view -| `wanted` | boolean | tr_file_view +| `wanted` | number | tr_file_view (**Note:** For backwards compatibility, this is serialized as an array of `0` or `1` that should be treated as booleans) | `priority` | number | tr_file_view `peers`: an array of objects, each containing: @@ -1000,4 +1000,4 @@ Transmission 4.0.0 (`rpc-version-semver` 5.3.0, `rpc-version`: 17) | `torrent-set` | :warning: **DEPRECATED** `trackerReplace`. Use `trackerList` instead. | `group-set` | new method | `group-get` | new method - +| `wanted` | :warning: Transmission 3.00 and earlier sent this as an array of `0` or `1` despite being documented as an array of booleans. Transmission 4.0.0 and 4.0.1 "fixed" this by returning an array of booleans, but as a practical matter this caused an unannounced breaking change for 3rd party code that expects `0` or `1`. For this reason, 4.0.2 restores the 3.00 behavior and updates this spec to match the code. diff --git a/libtransmission/rpcimpl.cc b/libtransmission/rpcimpl.cc index c7e95e81a..1fa698579 100644 --- a/libtransmission/rpcimpl.cc +++ b/libtransmission/rpcimpl.cc @@ -853,7 +853,7 @@ void initField(tr_torrent const* const tor, tr_stat const* const st, tr_variant* tr_variantInitList(initme, n); for (tr_file_index_t i = 0; i < n; ++i) { - tr_variantListAddBool(initme, tr_torrentFile(tor, i).wanted); + tr_variantListAddInt(initme, tr_torrentFile(tor, i).wanted); } } break;