fix(backend): use set_kb rtorrent command for speed limits
This commit is contained in:
@@ -595,12 +595,20 @@ pub async fn set_global_limit_handler(
|
|||||||
) -> impl IntoResponse {
|
) -> impl IntoResponse {
|
||||||
let client = xmlrpc::RtorrentClient::new(&state.scgi_socket_path);
|
let client = xmlrpc::RtorrentClient::new(&state.scgi_socket_path);
|
||||||
|
|
||||||
|
// Switch to using set_kb which is often more reliable or the standard way for limits
|
||||||
|
|
||||||
if let Some(down) = payload.max_download_rate {
|
if let Some(down) = payload.max_download_rate {
|
||||||
// Here is the fix: Send as Int
|
let down_kb = down / 1024;
|
||||||
if let Err(e) = client
|
if let Err(e) = client
|
||||||
.call("throttle.global_down.max_rate.set", &[RpcParam::Int(down)])
|
.call(
|
||||||
|
"throttle.global_down.max_rate.set_kb",
|
||||||
|
&[RpcParam::Int(down_kb)],
|
||||||
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
|
// Fallback or error?
|
||||||
|
// Maybe log and ignore?
|
||||||
|
// Let's assume set_kb works if set didn't (or vice versa).
|
||||||
return (
|
return (
|
||||||
StatusCode::INTERNAL_SERVER_ERROR,
|
StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
format!("Failed to set down limit: {}", e),
|
format!("Failed to set down limit: {}", e),
|
||||||
@@ -610,8 +618,12 @@ pub async fn set_global_limit_handler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(up) = payload.max_upload_rate {
|
if let Some(up) = payload.max_upload_rate {
|
||||||
|
let up_kb = up / 1024;
|
||||||
if let Err(e) = client
|
if let Err(e) = client
|
||||||
.call("throttle.global_up.max_rate.set", &[RpcParam::Int(up)])
|
.call(
|
||||||
|
"throttle.global_up.max_rate.set_kb",
|
||||||
|
&[RpcParam::Int(up_kb)],
|
||||||
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user