From 83db648b3cfadf53a3b7b994e2672d563c787437 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 13 Feb 2022 01:27:47 -0600 Subject: [PATCH] Add support for torrent-get calls with the key percentComplete (#2615) Co-authored-by: Michael Hadam --- extras/rpc-spec.md | 6 ++++-- libtransmission/quark.cc | 3 ++- libtransmission/quark.h | 1 + libtransmission/rpcimpl.cc | 4 ++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/extras/rpc-spec.md b/extras/rpc-spec.md index 0f49f0c68..1db02b1a6 100644 --- a/extras/rpc-spec.md +++ b/extras/rpc-spec.md @@ -248,7 +248,8 @@ The 'source' column here corresponds to the data structure there. | `peersFrom` | object (see below)| n/a | `peersGettingFromUs` | number| tr_stat | `peersSendingToUs` | number| tr_stat -| `percentDone` | double| tr_stat +| `percentComplete` | double | tr_stat +| `percentDone` | double | tr_stat | `pieces` | string (see below)| tr_torrent | `pieceCount`| number| tr_torrent_view | `pieceSize`| number| tr_torrent_view @@ -938,9 +939,10 @@ Transmission 4.0.0 (`rpc-version-semver` 5.3.0, `rpc-version`: 17) | `session-get` | new arg `script-torrent-added-filename` | `torrent-add` | new arg `labels` | `torrent-get` | new arg `file-count` +| `torrent-get` | new arg `percentComplete` +| `torrent-get` | new arg `primary-mime-type` | `torrent-get` | new arg `tracker.sitename` | `torrent-get` | new arg `trackerStats.sitename` -| `torrent-get` | new arg `primary-mime-type` ### 5.1. Upcoming Breakage diff --git a/libtransmission/quark.cc b/libtransmission/quark.cc index 17aac83c6..11121aa64 100644 --- a/libtransmission/quark.cc +++ b/libtransmission/quark.cc @@ -18,7 +18,7 @@ using namespace std::literals; namespace { -auto constexpr my_static = std::array{ ""sv, +auto constexpr my_static = std::array{ ""sv, "activeTorrentCount"sv, "activity-date"sv, "activityDate"sv, @@ -230,6 +230,7 @@ auto constexpr my_static = std::array{ ""sv, "peersFrom"sv, "peersGettingFromUs"sv, "peersSendingToUs"sv, + "percentComplete"sv, "percentDone"sv, "pex-enabled"sv, "piece"sv, diff --git a/libtransmission/quark.h b/libtransmission/quark.h index 62b2b0a51..99d3184d9 100644 --- a/libtransmission/quark.h +++ b/libtransmission/quark.h @@ -233,6 +233,7 @@ enum TR_KEY_peersFrom, TR_KEY_peersGettingFromUs, TR_KEY_peersSendingToUs, + TR_KEY_percentComplete, TR_KEY_percentDone, TR_KEY_pex_enabled, TR_KEY_piece, diff --git a/libtransmission/rpcimpl.cc b/libtransmission/rpcimpl.cc index 943838b33..09aef5ca4 100644 --- a/libtransmission/rpcimpl.cc +++ b/libtransmission/rpcimpl.cc @@ -633,6 +633,10 @@ static void initField(tr_torrent const* const tor, tr_stat const* const st, tr_v tr_variantInitStrView(initme, tr_torrentName(tor)); break; + case TR_KEY_percentComplete: + tr_variantInitReal(initme, st->percentComplete); + break; + case TR_KEY_percentDone: tr_variantInitReal(initme, st->percentDone); break;