Skip to content

Commit

Permalink
Merge pull request #257 from izderadicka/client-api-only
Browse files Browse the repository at this point in the history
Add CLI parameter to allow send downloads to remote server
  • Loading branch information
ikatson authored Oct 27, 2024
2 parents 946ad36 + bac3647 commit 588e6cd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 3 additions & 1 deletion crates/librqbit/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,9 @@ impl Session {
}

pub async fn pause(&self, handle: &ManagedTorrentHandle) -> anyhow::Result<()> {
handle.pause().map(|_| handle.locked.write().paused = true)?;
handle
.pause()
.map(|_| handle.locked.write().paused = true)?;
self.try_update_persistence_metadata(handle).await;
Ok(())
}
Expand Down
11 changes: 10 additions & 1 deletion crates/rqbit/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ struct DownloadOpts {

#[arg(long = "initial-peers")]
initial_peers: Option<InitialPeers>,

#[arg(long = "server-url")]
server_url: Option<String>,
}

#[derive(Clone)]
Expand Down Expand Up @@ -634,7 +637,10 @@ async fn async_main(opts: Opts, cancel: CancellationToken) -> anyhow::Result<()>
if download_opts.torrent_path.is_empty() {
anyhow::bail!("you must provide at least one URL to download")
}
let http_api_url = format!("http://{}", opts.http_api_listen_addr);
let http_api_url = download_opts
.server_url
.clone()
.unwrap_or_else(|| format!("http://{}", opts.http_api_listen_addr));
let client = http_api_client::HttpApiClient::new(&http_api_url)?;

let torrent_opts = |with_output_folder: bool| AddTorrentOptions {
Expand Down Expand Up @@ -662,6 +668,9 @@ async fn async_main(opts: Opts, cancel: CancellationToken) -> anyhow::Result<()>
false
}
};
if !connect_to_existing && download_opts.server_url.is_some() {
anyhow::bail!("cannot connect to server at {}", client.base_url());
}
if connect_to_existing {
for torrent_url in &download_opts.torrent_path {
match client
Expand Down

0 comments on commit 588e6cd

Please sign in to comment.