remove upload features as not planed in the crawler context

This commit is contained in:
yggverse 2025-08-10 16:11:09 +03:00
parent ef4871796c
commit 6285b850ce
2 changed files with 12 additions and 57 deletions

View file

@ -46,21 +46,6 @@ pub struct Config {
#[arg(long)] #[arg(long)]
pub bind: Option<String>, pub bind: Option<String>,
/// Bind listener on specified `host:port` (`[host]:port` for IPv6)
///
/// * this option is useful only for binding the data exchange service,
/// to restrict the outgoing connections for torrent resolver, use `bind` option instead
#[arg(long)]
pub listen: Option<SocketAddr>,
/// Enable UPnP forwarding
#[arg(long, default_value_t = false)]
pub listen_upnp: bool,
/// Enable upload (share bytes received with BitTorrent network)
#[arg(long, default_value_t = false)]
pub enable_upload: bool,
/// Directory path to store preloaded data (e.g. `.torrent` files) /// Directory path to store preloaded data (e.g. `.torrent` files)
#[arg(long)] #[arg(long)]
pub preload: PathBuf, pub preload: PathBuf,
@ -113,10 +98,6 @@ pub struct Config {
#[arg(long, default_value_t = 300)] #[arg(long, default_value_t = 300)]
pub sleep: u64, pub sleep: u64,
/// Limit upload speed (b/s)
#[arg(long)]
pub upload_limit: Option<u32>,
/// Limit download speed (b/s) /// Limit download speed (b/s)
#[arg(long)] #[arg(long)]
pub download_limit: Option<u32>, pub download_limit: Option<u32>,

View file

@ -5,8 +5,8 @@ mod preload;
use anyhow::Result; use anyhow::Result;
use config::Config; use config::Config;
use librqbit::{ use librqbit::{
AddTorrent, AddTorrentOptions, AddTorrentResponse, ConnectionOptions, ListenerOptions, AddTorrent, AddTorrentOptions, AddTorrentResponse, ConnectionOptions, PeerConnectionOptions,
PeerConnectionOptions, SessionOptions, SessionOptions,
}; };
use preload::Preload; use preload::Preload;
use std::{collections::HashSet, num::NonZero, time::Duration}; use std::{collections::HashSet, num::NonZero, time::Duration};
@ -35,19 +35,7 @@ async fn main() -> Result<()> {
SessionOptions { SessionOptions {
bind_device_name: config.bind, bind_device_name: config.bind,
blocklist_url: config.blocklist.map(|b| b.into()), blocklist_url: config.blocklist.map(|b| b.into()),
listen: match config.listen { listen: None,
Some(listen_addr) => Some(ListenerOptions {
enable_upnp_port_forwarding: config.listen_upnp,
listen_addr,
..ListenerOptions::default()
}),
None => {
if config.listen_upnp {
panic!("`--listen` argument is required!")
}
None
}
},
connect: Some(ConnectionOptions { connect: Some(ConnectionOptions {
enable_tcp: !config.disable_tcp, enable_tcp: !config.disable_tcp,
proxy_url: config.proxy_url.map(|u| u.to_string()), proxy_url: config.proxy_url.map(|u| u.to_string()),
@ -60,11 +48,11 @@ async fn main() -> Result<()> {
disable_dht_persistence: true, disable_dht_persistence: true,
disable_dht: !config.enable_dht, disable_dht: !config.enable_dht,
disable_local_service_discovery: !config.enable_lsd, disable_local_service_discovery: !config.enable_lsd,
disable_upload: !config.enable_upload, disable_upload: true,
persistence: None, persistence: None,
ratelimits: librqbit::limits::LimitsConfig { ratelimits: librqbit::limits::LimitsConfig {
upload_bps: config.upload_limit.and_then(NonZero::new),
download_bps: config.download_limit.and_then(NonZero::new), download_bps: config.download_limit.and_then(NonZero::new),
..librqbit::limits::LimitsConfig::default()
}, },
trackers: config.tracker.iter().cloned().collect(), trackers: config.tracker.iter().cloned().collect(),
..SessionOptions::default() ..SessionOptions::default()
@ -191,13 +179,9 @@ async fn main() -> Result<()> {
log::debug!( log::debug!(
"skip awaiting the completion of preload `{i}` data (`{e}`)" "skip awaiting the completion of preload `{i}` data (`{e}`)"
); );
if config.enable_upload {
todo!()
} else {
session session
.delete(librqbit::api::TorrentIdOrHash::Id(id), false) .delete(librqbit::api::TorrentIdOrHash::Id(id), false)
.await? .await?;
}
continue; continue;
} }
log::debug!("torrent `{i}` preload completed."); log::debug!("torrent `{i}` preload completed.");
@ -208,22 +192,12 @@ async fn main() -> Result<()> {
keep_files.len() keep_files.len()
); );
preload.commit(&i, bytes, Some(keep_files))?; preload.commit(&i, bytes, Some(keep_files))?;
if !config.enable_upload {
session session
.delete(librqbit::api::TorrentIdOrHash::Id(id), false) .delete(librqbit::api::TorrentIdOrHash::Id(id), false)
.await? .await?;
}
log::debug!("torrent `{i}` resolved.") log::debug!("torrent `{i}` resolved.")
} }
Ok(AddTorrentResponse::AlreadyManaged(..)) => { Ok(_) => panic!(),
if config.enable_upload {
todo!()
//log::debug!("keep sharing the existing torrent data for `{i}`.")
} else {
panic!("torrent `{i}` was not removed properly!")
}
}
Ok(_) => panic!("list only mode is not expected by the implementation!"),
Err(e) => log::debug!("failed to resolve torrent `{i}`: `{e}`."), Err(e) => log::debug!("failed to resolve torrent `{i}`: `{e}`."),
}, },
Err(e) => log::debug!( Err(e) => log::debug!(