From 9313e42866559a5a140d47caa359c15054e8f84f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luukas=20P=C3=B6rtfors?= Date: Wed, 19 Oct 2022 02:02:23 +0300 Subject: [PATCH] remote: improve and document the rename command (#3973) --- utils/remote.cc | 8 ++++---- utils/transmission-remote.1 | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/utils/remote.cc b/utils/remote.cc index 6e0e4ade8..03852803e 100644 --- a/utils/remote.cc +++ b/utils/remote.cc @@ -2406,8 +2406,6 @@ static tr_variant* ensure_tset(tr_variant* tset) return tr_variantDictAddDict(tset, Arguments, 1); } -static char rename_from[4096]; - static int processArgs(char const* rpcurl, int argc, char const* const* argv, Config& config) { int status = EXIT_SUCCESS; @@ -2415,6 +2413,7 @@ static int processArgs(char const* rpcurl, int argc, char const* const* argv, Co auto sset = tr_variant{}; auto tset = tr_variant{}; auto tadd = tr_variant{}; + std::string rename_from; for (;;) { @@ -3167,18 +3166,19 @@ static int processArgs(char const* rpcurl, int argc, char const* const* argv, Co { auto top = tr_variant{}; tr_variantInitDict(&top, 2); - tr_variantDictAddStr(&top, TR_KEY_method, "rename"); + tr_variantDictAddStr(&top, TR_KEY_method, "torrent-rename-path"sv); auto* args = tr_variantDictAddDict(&top, Arguments, 3); tr_variantDictAddStr(args, TR_KEY_path, rename_from); tr_variantDictAddStr(args, TR_KEY_name, optarg); addIdArg(args, config); status |= flush(rpcurl, &top, config); + rename_from.clear(); break; } case 965: { - tr_strlcpy(rename_from, optarg, sizeof(rename_from)); + rename_from = optarg; break; } diff --git a/utils/transmission-remote.1 b/utils/transmission-remote.1 index 0bb63cdb9..54e584ee5 100644 --- a/utils/transmission-remote.1 +++ b/utils/transmission-remote.1 @@ -258,6 +258,10 @@ Remove the current torrent(s) and delete their downloaded data. Reannounce the current torrent(s). This is the same as the GUI's "ask tracker for more peers" button. .It Fl -move Move the current torrents' data from their current locations to the specified directory. +.It Fl -rename Ar newname +Rename files or root folder of a torrent +.It Fl -path Ar oldname +Provide original path for the rename command .It Fl -unix-socket Connect using a Unix domain socket. .It Fl -find @@ -363,6 +367,10 @@ List all torrents with name containing "def" or with label "abc": .Bd -literal -offset indent $ transmission-remote -t $(\ transmission-remote \-F n:def \-ids )$(\ transmission-remote \-F l:abc \-ids ) \-l .Ed +Rename torrent root folder from "test1/examplefile.txt" to "test2/examplefile.txt" +.Bd -literal -offset indent +$ transmission-remote -t1 --path test1 --rename test2 +.Ed Set download and upload limits to 400 kB/sec and 60 kB/sec: .Bd -literal -offset indent $ transmission-remote \-d400 \-u60