From 2ac76683e620e3352492e8a11c78e1c7035308cd Mon Sep 17 00:00:00 2001 From: Igor Katson Date: Sun, 10 Oct 2021 10:46:09 +0100 Subject: [PATCH] Now actually downloads 2 files at a time --- crates/librqbit/src/http_api.rs | 6 +++--- crates/rqbit/src/main.rs | 17 +++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/crates/librqbit/src/http_api.rs b/crates/librqbit/src/http_api.rs index 6172330..96c3e20 100644 --- a/crates/librqbit/src/http_api.rs +++ b/crates/librqbit/src/http_api.rs @@ -287,7 +287,7 @@ impl HttpApi { Ok(idx) => { return Ok(make_response(200, format!("{}", idx))); } - Err(e) => return Ok(make_response(400, format!("{}", e))), + Err(e) => return Ok(make_response(400, format!("{:#}", e))), } } } @@ -312,13 +312,13 @@ impl HttpApi { }); let router = api_list - .or(torrent_list) .or(dht_stats) .or(dht_routing_table) .or(torrent_details) .or(torrent_dump_haves) .or(torrent_dump_stats) - .or(torrent_add); + .or(torrent_add) + .or(torrent_list); warp::serve(router).run(addr).await; Ok(()) diff --git a/crates/rqbit/src/main.rs b/crates/rqbit/src/main.rs index a18165d..6abfbe2 100644 --- a/crates/rqbit/src/main.rs +++ b/crates/rqbit/src/main.rs @@ -155,14 +155,6 @@ async fn async_main(opts: Opts, spawner: BlockingSpawner) -> anyhow::Result<()> .context("error initializing rqbit session")?, ); - { - let http_api = HttpApi::new(session.clone()); - spawn("HTTP API", { - let http_api_listen_addr = opts.http_api_listen_addr; - async move { http_api.make_http_api_and_run(http_api_listen_addr).await } - }); - }; - let torrent_opts = AddTorrentOptions { only_files_regex: opts.only_files_matching_regex, overwrite: opts.overwrite, @@ -180,6 +172,15 @@ async fn async_main(opts: Opts, spawner: BlockingSpawner) -> anyhow::Result<()> None => return Ok(()), }; + { + let http_api = HttpApi::new(session.clone()); + http_api.add_mgr(handle.clone()); + spawn("HTTP API", { + let http_api_listen_addr = opts.http_api_listen_addr; + async move { http_api.make_http_api_and_run(http_api_listen_addr).await } + }); + }; + spawn("Stats printer", { let handle = handle.clone(); async move {