mirror of
https://github.com/transmission/transmission
synced 2025-03-13 07:33:02 +00:00
feat: sequential download cmdline options in remote and daemon (#7048)
* feat: add seq option in remote * feat: print session sequential download setting in remote * refactor: assert options torrent size in daemon * feat: add seq option in daemon
This commit is contained in:
parent
40d73978f7
commit
86e904d1a2
2 changed files with 54 additions and 2 deletions
|
@ -77,7 +77,7 @@ char constexpr Usage[] = "Transmission " LONG_VERSION_STRING
|
||||||
|
|
||||||
// --- Config File
|
// --- Config File
|
||||||
|
|
||||||
auto constexpr Options = std::array<tr_option, 45>{
|
auto constexpr Options = std::array<tr_option, 47>{
|
||||||
{ { 'a', "allowed", "Allowed IP addresses. (Default: " TR_DEFAULT_RPC_WHITELIST ")", "a", true, "<list>" },
|
{ { 'a', "allowed", "Allowed IP addresses. (Default: " TR_DEFAULT_RPC_WHITELIST ")", "a", true, "<list>" },
|
||||||
{ 'b', "blocklist", "Enable peer blocklists", "b", false, nullptr },
|
{ 'b', "blocklist", "Enable peer blocklists", "b", false, nullptr },
|
||||||
{ 'B', "no-blocklist", "Disable peer blocklists", "B", false, nullptr },
|
{ 'B', "no-blocklist", "Disable peer blocklists", "B", false, nullptr },
|
||||||
|
@ -141,9 +141,12 @@ auto constexpr Options = std::array<tr_option, 45>{
|
||||||
"GSR",
|
"GSR",
|
||||||
false,
|
false,
|
||||||
nullptr },
|
nullptr },
|
||||||
|
{ 994, "sequential-download", "Enable sequential download by default", "seq", false, nullptr },
|
||||||
|
{ 995, "no-sequential-download", "Disable sequential download by default", "SEQ", false, nullptr },
|
||||||
{ 'x', "pid-file", "Enable PID file", "x", true, "<pid-file>" },
|
{ 'x', "pid-file", "Enable PID file", "x", true, "<pid-file>" },
|
||||||
{ 0, nullptr, nullptr, nullptr, false, nullptr } }
|
{ 0, nullptr, nullptr, nullptr, false, nullptr } }
|
||||||
};
|
};
|
||||||
|
static_assert(Options[std::size(Options) - 2].val != 0);
|
||||||
|
|
||||||
[[nodiscard]] std::string getConfigDir(int argc, char const* const* argv)
|
[[nodiscard]] std::string getConfigDir(int argc, char const* const* argv)
|
||||||
{
|
{
|
||||||
|
@ -487,6 +490,14 @@ bool tr_daemon::parse_args(int argc, char const* const* argv, bool* dump_setting
|
||||||
tr_variantDictAddStr(&settings_, TR_KEY_default_trackers, optstr);
|
tr_variantDictAddStr(&settings_, TR_KEY_default_trackers, optstr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 994:
|
||||||
|
tr_variantDictAddBool(&settings_, TR_KEY_sequentialDownload, true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 995:
|
||||||
|
tr_variantDictAddBool(&settings_, TR_KEY_sequentialDownload, false);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
*dump_settings = true;
|
*dump_settings = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -210,7 +210,7 @@ enum
|
||||||
|
|
||||||
// --- Command-Line Arguments
|
// --- Command-Line Arguments
|
||||||
|
|
||||||
auto constexpr Options = std::array<tr_option, 103>{
|
auto constexpr Options = std::array<tr_option, 105>{
|
||||||
{ { 'a', "add", "Add torrent files by filename or URL", "a", false, nullptr },
|
{ { 'a', "add", "Add torrent files by filename or URL", "a", false, nullptr },
|
||||||
{ 970, "alt-speed", "Use the alternate Limits", "as", false, nullptr },
|
{ 970, "alt-speed", "Use the alternate Limits", "as", false, nullptr },
|
||||||
{ 971, "no-alt-speed", "Don't use the alternate Limits", "AS", false, nullptr },
|
{ 971, "no-alt-speed", "Don't use the alternate Limits", "AS", false, nullptr },
|
||||||
|
@ -339,6 +339,8 @@ auto constexpr Options = std::array<tr_option, 103>{
|
||||||
{ 991, "no-start-paused", "Start added torrents unpaused", nullptr, false, nullptr },
|
{ 991, "no-start-paused", "Start added torrents unpaused", nullptr, false, nullptr },
|
||||||
{ 992, "trash-torrent", "Delete torrents after adding", nullptr, false, nullptr },
|
{ 992, "trash-torrent", "Delete torrents after adding", nullptr, false, nullptr },
|
||||||
{ 993, "no-trash-torrent", "Do not delete torrents after adding", nullptr, false, nullptr },
|
{ 993, "no-trash-torrent", "Do not delete torrents after adding", nullptr, false, nullptr },
|
||||||
|
{ 994, "sequential-download", "Download the torrent sequentially", "seq", false, nullptr },
|
||||||
|
{ 995, "no-sequential-download", "Download the torrent sequentially", "SEQ", false, nullptr },
|
||||||
{ 984, "honor-session", "Make the current torrent(s) honor the session limits", "hl", false, nullptr },
|
{ 984, "honor-session", "Make the current torrent(s) honor the session limits", "hl", false, nullptr },
|
||||||
{ 985, "no-honor-session", "Make the current torrent(s) not honor the session limits", "HL", false, nullptr },
|
{ 985, "no-honor-session", "Make the current torrent(s) not honor the session limits", "HL", false, nullptr },
|
||||||
{ 'u',
|
{ 'u',
|
||||||
|
@ -500,6 +502,10 @@ enum
|
||||||
case 930: /* peers */
|
case 930: /* peers */
|
||||||
return MODE_SESSION_SET | MODE_TORRENT_SET;
|
return MODE_SESSION_SET | MODE_TORRENT_SET;
|
||||||
|
|
||||||
|
case 994: /* sequential-download */
|
||||||
|
case 995: /* no-sequential-download */
|
||||||
|
return MODE_SESSION_SET | MODE_TORRENT_SET | MODE_TORRENT_ADD;
|
||||||
|
|
||||||
case 'r': /* remove */
|
case 'r': /* remove */
|
||||||
case 840: /* remove and delete */
|
case 840: /* remove and delete */
|
||||||
return MODE_TORRENT_REMOVE;
|
return MODE_TORRENT_REMOVE;
|
||||||
|
@ -1831,6 +1837,11 @@ void print_session(tr_variant::Map const& map)
|
||||||
fmt::print(" Maximum memory cache size: {:s}\n", Memory{ *i, Memory::Units::MBytes }.to_string());
|
fmt::print(" Maximum memory cache size: {:s}\n", Memory{ *i, Memory::Units::MBytes }.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (auto b = args->value_if<bool>(TR_KEY_sequentialDownload); b)
|
||||||
|
{
|
||||||
|
fmt::print(" Sequential download: {:s}\n", *b ? "Yes" : "No");
|
||||||
|
}
|
||||||
|
|
||||||
auto const alt_enabled = args->value_if<bool>(TR_KEY_alt_speed_enabled);
|
auto const alt_enabled = args->value_if<bool>(TR_KEY_alt_speed_enabled);
|
||||||
auto const alt_time_enabled = args->value_if<bool>(TR_KEY_alt_speed_time_enabled);
|
auto const alt_time_enabled = args->value_if<bool>(TR_KEY_alt_speed_time_enabled);
|
||||||
auto const up_enabled = args->value_if<bool>(TR_KEY_speed_limit_up_enabled);
|
auto const up_enabled = args->value_if<bool>(TR_KEY_speed_limit_up_enabled);
|
||||||
|
@ -3111,6 +3122,36 @@ int process_args(char const* rpcurl, int argc, char const* const* argv, RemoteCo
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (step_mode == (MODE_SESSION_SET | MODE_TORRENT_SET | MODE_TORRENT_ADD))
|
||||||
|
{
|
||||||
|
tr_variant::Map& args = [&]() -> tr_variant::Map&
|
||||||
|
{
|
||||||
|
if (tadd.has_value())
|
||||||
|
{
|
||||||
|
return ensure_tadd(tadd);
|
||||||
|
}
|
||||||
|
if (!std::empty(config.torrent_ids))
|
||||||
|
{
|
||||||
|
return ensure_tset(tset);
|
||||||
|
}
|
||||||
|
return ensure_sset(sset);
|
||||||
|
}();
|
||||||
|
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case 994:
|
||||||
|
args.insert_or_assign(TR_KEY_sequentialDownload, true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 995:
|
||||||
|
args.insert_or_assign(TR_KEY_sequentialDownload, false);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
TR_ASSERT_MSG(false, "unhandled value");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (step_mode == MODE_TORRENT_REMOVE)
|
else if (step_mode == MODE_TORRENT_REMOVE)
|
||||||
{
|
{
|
||||||
auto map = tr_variant::Map{ 2 };
|
auto map = tr_variant::Map{ 2 };
|
||||||
|
|
Loading…
Add table
Reference in a new issue