mirror of
https://github.com/YGGverse/aquatic-crawler.git
synced 2026-03-31 09:05:33 +00:00
implement slow_torrent_ban argument option
This commit is contained in:
parent
186c2b6cf1
commit
129d33f593
2 changed files with 16 additions and 4 deletions
|
|
@ -98,7 +98,7 @@ pub struct Config {
|
||||||
#[arg(long, default_value_t = 60)]
|
#[arg(long, default_value_t = 60)]
|
||||||
pub add_torrent_timeout: u64,
|
pub add_torrent_timeout: u64,
|
||||||
|
|
||||||
/// Ban time in seconds on torrent add failure
|
/// Ban time in seconds on torrent add failure (`add_torrent_timeout` is reached)
|
||||||
#[arg(long, default_value_t = 3600)]
|
#[arg(long, default_value_t = 3600)]
|
||||||
pub add_torrent_ban: u64,
|
pub add_torrent_ban: u64,
|
||||||
|
|
||||||
|
|
@ -106,6 +106,10 @@ pub struct Config {
|
||||||
#[arg(long, default_value_t = 3600)]
|
#[arg(long, default_value_t = 3600)]
|
||||||
pub resolve_torrent_ban: u64,
|
pub resolve_torrent_ban: u64,
|
||||||
|
|
||||||
|
/// Ban time in seconds on torrent data download is longer than `add_torrent_timeout`
|
||||||
|
#[arg(long)]
|
||||||
|
pub slow_torrent_ban: Option<u64>,
|
||||||
|
|
||||||
/// Crawl loop delay in seconds
|
/// Crawl loop delay in seconds
|
||||||
#[arg(long, default_value_t = 60)]
|
#[arg(long, default_value_t = 60)]
|
||||||
pub sleep: u64,
|
pub sleep: u64,
|
||||||
|
|
|
||||||
14
src/main.rs
14
src/main.rs
|
|
@ -198,12 +198,20 @@ async fn main() -> Result<()> {
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
log::debug!(
|
|
||||||
"skip awaiting the completion of preload `{h}` data (`{e}`)"
|
|
||||||
);
|
|
||||||
session
|
session
|
||||||
.delete(librqbit::api::TorrentIdOrHash::Id(id), false)
|
.delete(librqbit::api::TorrentIdOrHash::Id(id), false)
|
||||||
.await?; // * do not collect billions of slow torrents in the session pool
|
.await?; // * do not collect billions of slow torrents in the session pool
|
||||||
|
if let Some(slow_torrent_ban) = config.slow_torrent_ban {
|
||||||
|
let t = Local::now() + Duration::from_secs(slow_torrent_ban);
|
||||||
|
log::debug!(
|
||||||
|
"skip awaiting the completion of preload `{h}` data (`{e}`), ban until {t}."
|
||||||
|
);
|
||||||
|
assert!(ban.insert(i, t).is_none());
|
||||||
|
} else {
|
||||||
|
log::debug!(
|
||||||
|
"skip awaiting the completion of preload `{h}` data (`{e}`)"
|
||||||
|
);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
log::debug!("torrent `{h}` preload completed.");
|
log::debug!("torrent `{h}` preload completed.");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue