mirror of
https://github.com/transmission/transmission.git
synced 2026-02-15 07:26:49 +00:00
fix(remote): attach id to methods that can return errors (#8028)
* fix(remote): attach id to `session_set` requests * fix(remote): attach id to `torrent_set` requests * fix(remote): attach id to `torrent_set_location` requests * fix(remote): attach id to `torrent_rename_path` requests
This commit is contained in:
@@ -198,6 +198,7 @@ struct RemoteConfig
|
||||
|
||||
enum
|
||||
{
|
||||
ID_NOOP,
|
||||
ID_SESSION,
|
||||
ID_STATS,
|
||||
ID_DETAILS,
|
||||
@@ -2293,7 +2294,7 @@ int process_response(char const* rpcurl, std::string_view const response, Remote
|
||||
auto* result = top->find_if<tr_variant::Map>(TR_KEY_result);
|
||||
result = result ? result : &empty_result;
|
||||
|
||||
switch (top->value_if<int64_t>(TR_KEY_id).value_or(-1))
|
||||
switch (top->value_if<int64_t>(TR_KEY_id).value_or(ID_NOOP))
|
||||
{
|
||||
case ID_SESSION:
|
||||
print_session(*result);
|
||||
@@ -2517,6 +2518,7 @@ tr_variant::Map& ensure_sset(tr_variant& sset)
|
||||
map = sset.get_if<tr_variant::Map>();
|
||||
map->try_emplace(TR_KEY_jsonrpc, tr_variant::unmanaged_string(JsonRpc::Version));
|
||||
map->try_emplace(TR_KEY_method, tr_variant::unmanaged_string(TR_KEY_session_set));
|
||||
map->try_emplace(TR_KEY_id, ID_NOOP);
|
||||
}
|
||||
|
||||
auto* params = map->find_if<tr_variant::Map>(TR_KEY_params);
|
||||
@@ -2532,10 +2534,11 @@ tr_variant::Map& ensure_tset(tr_variant& tset)
|
||||
auto* map = tset.get_if<tr_variant::Map>();
|
||||
if (map == nullptr)
|
||||
{
|
||||
tset = tr_variant::Map{ 3 };
|
||||
tset = tr_variant::Map{ 4U };
|
||||
map = tset.get_if<tr_variant::Map>();
|
||||
map->try_emplace(TR_KEY_jsonrpc, tr_variant::unmanaged_string(JsonRpc::Version));
|
||||
map->try_emplace(TR_KEY_method, tr_variant::unmanaged_string(TR_KEY_torrent_set));
|
||||
map->try_emplace(TR_KEY_id, ID_NOOP);
|
||||
}
|
||||
|
||||
auto* params = map->find_if<tr_variant::Map>(TR_KEY_params);
|
||||
@@ -3380,10 +3383,11 @@ int process_args(char const* rpcurl, int argc, char const* const* argv, RemoteCo
|
||||
params.try_emplace(TR_KEY_move, true);
|
||||
add_id_arg(params, config);
|
||||
|
||||
auto map = tr_variant::Map{ 3U };
|
||||
auto map = tr_variant::Map{ 4U };
|
||||
map.try_emplace(TR_KEY_jsonrpc, tr_variant::unmanaged_string(JsonRpc::Version));
|
||||
map.try_emplace(TR_KEY_method, tr_variant::unmanaged_string(TR_KEY_torrent_set_location));
|
||||
map.try_emplace(TR_KEY_params, std::move(params));
|
||||
map.try_emplace(TR_KEY_id, ID_NOOP);
|
||||
|
||||
auto top = tr_variant{ std::move(map) };
|
||||
status |= flush(rpcurl, &top, config);
|
||||
@@ -3410,10 +3414,11 @@ int process_args(char const* rpcurl, int argc, char const* const* argv, RemoteCo
|
||||
params.try_emplace(TR_KEY_move, false);
|
||||
add_id_arg(params, config);
|
||||
|
||||
auto map = tr_variant::Map{ 3U };
|
||||
auto map = tr_variant::Map{ 4U };
|
||||
map.try_emplace(TR_KEY_jsonrpc, tr_variant::unmanaged_string(JsonRpc::Version));
|
||||
map.try_emplace(TR_KEY_method, tr_variant::unmanaged_string(TR_KEY_torrent_set_location));
|
||||
map.try_emplace(TR_KEY_params, std::move(params));
|
||||
map.try_emplace(TR_KEY_id, ID_NOOP);
|
||||
|
||||
auto top = tr_variant{ std::move(map) };
|
||||
status |= flush(rpcurl, &top, config);
|
||||
@@ -3427,10 +3432,11 @@ int process_args(char const* rpcurl, int argc, char const* const* argv, RemoteCo
|
||||
args.try_emplace(TR_KEY_name, optarg_sv);
|
||||
add_id_arg(args, config);
|
||||
|
||||
auto map = tr_variant::Map{ 3U };
|
||||
auto map = tr_variant::Map{ 4U };
|
||||
map.try_emplace(TR_KEY_jsonrpc, tr_variant::unmanaged_string(JsonRpc::Version));
|
||||
map.try_emplace(TR_KEY_method, tr_variant::unmanaged_string(TR_KEY_torrent_rename_path));
|
||||
map.try_emplace(TR_KEY_params, std::move(args));
|
||||
map.try_emplace(TR_KEY_id, ID_NOOP);
|
||||
|
||||
auto top = tr_variant{ std::move(map) };
|
||||
status |= flush(rpcurl, &top, config);
|
||||
|
||||
Reference in New Issue
Block a user